/* AppSite Agents */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde3ed;
  --text: #1a2332;
  --text-muted: #6b7a8f;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --radius: 8px;
  --sidebar-w: 220px;
}

html, body { width: 100%; height: 100%; min-height: 100%; overflow: hidden;   padding-bottom: 28px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app, .app, .app-shell { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#appsiteTopNav, #appsite-topnav, .appsite-topnav, .appsite-topnav-shell, header.appsite-topnav, .tl-topnav, .topnav-module {
  flex: 0 0 auto; width: 100%; max-width: 100%; z-index: 1000;
}

/* Status bar */
#statusBar { font-size: 12px; padding: 4px 16px; background: var(--primary-light); color: var(--primary); border-top: 1px solid var(--border); min-height: 24px; display: block; position: fixed; bottom: 0; left: 0; right: 0; z-index: 150; }
#statusBar:empty { padding: 0; min-height: 0; border-top: none; }
#statusBar.error { background: var(--danger-light); color: var(--danger); }

/* Layout */
.app-layout { display: flex; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px; border-bottom: 1px solid var(--border); }
.sidebar-title { font-size: 13px; font-weight: 700; color: var(--text); }
.sidebar-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 8px 12px 2px; }
.sidebar-scroll { flex: 1 1 auto; overflow-y: auto; padding: 4px 0; }
.sidebar-item { display: flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; cursor: pointer; border-radius: 0; color: var(--text); transition: background 0.1s; }
.sidebar-item:hover { background: var(--bg); }
.sidebar-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-empty { font-size: 12px; color: var(--text-muted); padding: 8px 12px; }

/* Agent type / status dots */
.agent-type-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.agent-type-dot.ai { background: var(--primary); }
.agent-type-dot.human { background: var(--success); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-left: auto; background: var(--text-muted); }
.status-dot.active { background: var(--success); }
.status-dot.away { background: var(--warn); }

/* Workspace */
.workspace { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.workspace-toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.workspace-header-group { display: flex; flex-direction: column; margin-right: auto; }
.workspace-title { font-size: 15px; font-weight: 700; color: var(--text); }
.workspace-subtitle { font-size: 11px; color: var(--text-muted); }
.workspace-scroll { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

/* Summary grid */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.summary-value { font-size: 22px; font-weight: 700; color: var(--text); }
.summary-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 13px; font-weight: 700; }
.card-body { padding: 0; overflow-x: auto; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 8px 12px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.muted { color: var(--text-muted); }

/* Badges */
.badge { display: inline-flex; align-items: center; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-ai { background: var(--primary-light); color: var(--primary); border-color: transparent; }
.badge-human { background: #f0fdf4; color: #16a34a; border-color: transparent; }
.badge-active { background: #f0fdf4; color: #16a34a; border-color: transparent; }

.status-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--text-muted); }
.status-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.status-chip.active { background: #f0fdf4; color: #16a34a; }
.status-chip.away { background: #fffbeb; color: #d97706; }
.status-chip.inactive { background: var(--bg); color: var(--text-muted); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; transition: background 0.15s, color 0.15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-surface { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-surface:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { font-size: 12px; padding: 4px 10px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.field-input { font-size: 13px; font-family: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; color: var(--text); background: var(--surface); outline: none; width: 100%; }
.field-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
textarea.field-input { resize: vertical; min-height: 60px; }
.form-grid { display: grid; gap: 10px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border-radius: 10px; box-shadow: 0 8px 40px rgba(0,0,0,0.18); width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-wide { max-width: 600px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* Landing page */
.landing-wrap { max-width: 880px; margin: 0 auto; padding: 60px 24px 40px; }
.landing-hero { text-align: center; margin-bottom: 48px; }
.eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--primary); margin-bottom: 8px; }
.landing-hero h1 { font-size: 42px; font-weight: 800; color: var(--text); margin-bottom: 14px; }
.landing-sub { font-size: 16px; color: var(--text-muted); max-width: 540px; margin: 0 auto 28px; }
.landing-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-signin { display: inline-flex; align-items: center; background: var(--primary); color: #fff; padding: 10px 24px; border-radius: 8px; font-weight: 700; font-size: 14px; text-decoration: none; }
.btn-signin:hover { background: var(--primary-hover); }
.btn-hub { display: inline-flex; align-items: center; background: var(--surface); color: var(--text); padding: 10px 24px; border-radius: 8px; font-weight: 600; font-size: 14px; text-decoration: none; border: 1px solid var(--border); }
.btn-hub:hover { background: var(--bg); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.feature-card svg { width: 24px; height: 24px; stroke: var(--primary); fill: none; stroke-width: 1.5; margin-bottom: 10px; }
.feature-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 13px; color: var(--text-muted); }
.landing-footer { text-align: center; padding: 24px; font-size: 12px; }
.landing-footer a { color: var(--text-muted); }

/* SSO banner */
.sso-banner { display: flex; align-items: center; gap: 10px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px; font-size: 13px; }
.sso-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.sso-name { font-weight: 600; }
.sso-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.btn-link { color: var(--primary); font-size: 13px; font-weight: 600; text-decoration: none; }
.btn-sm { font-size: 12px; padding: 4px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; cursor: pointer; }

/* .layout / .order-list / .order-editor pattern */
/* When editor is hidden, agent list fills full width */
#rosterLayout { grid-template-columns: 1fr !important; }
#rosterLayout:has(#agentEditor:not(.hidden)) { grid-template-columns: minmax(200px, 320px) 1fr !important; }
header.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: nowrap; flex-shrink: 0; overflow: hidden; }
header.topbar h1 { font-size: 15px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
header.topbar .actions { display: flex; flex-wrap: nowrap; gap: 4px; align-items: center; min-width: 0; overflow: hidden; flex: 1; justify-content: flex-end; }
header.topbar .actions input[type="search"], header.topbar .actions select { font-size: 11px; padding: 2px 6px; height: 26px; min-width: 80px; max-width: 140px; }
header.topbar .actions button, header.topbar .actions .btn { font-size: 11px; padding: 0 8px; height: 26px; white-space: nowrap; flex-shrink: 0; }
.workspace { display: flex; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
/* agents-body: sidebar + content side by side (hub pattern) */
.agents-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.agents-body .hub-sidebar {
  position: relative !important;
  top: auto !important;
  align-self: stretch !important;
  padding: 8px 4px !important;
  background: var(--surface) !important;
  border-right: 1px solid var(--border) !important;
  margin-right: 0 !important;
  /* Always vertical — never go horizontal at any breakpoint */
  width: var(--sidebar-w, 172px) !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  gap: 2px !important;
  overflow: hidden !important;
  transition: width var(--sidebar-transition) !important;
}
.agents-body .hub-sidebar.collapsed {
  width: var(--sidebar-collapsed-w, 36px) !important;
  overflow: visible !important;
  align-items: center !important;
}
.agents-content { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; padding: 12px; }
.order-item { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.order-item:hover { background: var(--bg); }
.order-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.order-item:last-child { border-bottom: 0; }
.order-editor { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius,8px); display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
.order-editor.hidden { display: none; }
.wo-header-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.wo-header-left { display: flex; align-items: center; gap: 10px; }
.wo-header-left h2 { font-size: 16px; font-weight: 700; }
.wo-status-chip { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-muted,#6b7280); background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 2px 9px; }
.wo-header-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn-primary-action { background: var(--primary); border: 1px solid var(--primary); color: #fff; font-weight: 600; padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; min-height: 32px; }
.wo-tabs { display: flex; gap: 2px; padding: 8px 20px 0; background: var(--surface); border-bottom: 2px solid var(--border); position: sticky; top: 57px; z-index: 9; flex-wrap: wrap; }
.wo-tab { padding: 7px 14px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: transparent; font: inherit; font-size: 12px; font-weight: 600; color: var(--text-muted,#6b7280); cursor: pointer; white-space: nowrap; }
.wo-tab.active { background: var(--surface); border-color: var(--border); color: var(--primary); margin-bottom: -2px; padding-bottom: 9px; }
.wo-tab-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; }
.wo-form { display: flex; flex-direction: column; }
.wo-row { display: flex; gap: 12px; }
.wo-row.four-col { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }

@media (max-width: 640px) {
  /* Header: single compact row on mobile */
  header.topbar { padding: 6px 12px; gap: 6px; }
  header.topbar h1 { font-size: 14px; }
  header.topbar .actions #searchInput { min-width: 80px; }
  header.topbar .actions #typeFilter { display: none; }

  /* Sidebar: horizontal pill strip across top instead of left rail */
  .agents-body { flex-direction: column; overflow: visible; }
  .agents-body .hub-sidebar {
    width: 100% !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    padding: 6px 8px !important;
    gap: 4px !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    align-self: auto !important;
    scrollbar-width: none !important;
  }
  .agents-body .hub-sidebar::-webkit-scrollbar { display: none; }
  .agents-body .hub-sidebar .sidebar-toggle-btn { display: none !important; }
  .agents-body .hub-sidebar .filter-chip {
    width: auto !important;
    flex-shrink: 0 !important;
    padding: 5px 14px !important;
    border-radius: 20px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    font-size: 12px !important;
  }
  .agents-body .hub-sidebar .filter-chip.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
  }

  /* Content: full width below the nav strip */
  .agents-content { padding: 8px; }

  /* Inner layout: stack list over editor */
  .layout { grid-template-columns: 1fr !important; overflow: auto; }
  .order-list { max-height: 240px; }
}
