/* ============================================================
   App Shell — Logged-in dashboard for receptionist / staff
   Built for readability, low-eye-strain daily use.
   ============================================================ */

body.app {
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  font-weight: 800; color: var(--slate-800);
  text-decoration: none;
}
.sidebar .brand .logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
  color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(44, 122, 123, 0.25);
}
.sidebar .brand .label { font-size: 0.94rem; line-height: 1.2; }
.sidebar .brand .label small { display: block; color: var(--text-soft); font-weight: 600; font-size: 0.72rem; }

.nav-section { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); padding: 14px 12px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--slate-700);
  font-weight: 600;
  font-size: 0.94rem;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--slate-100); color: var(--teal-700); text-decoration: none; }
.nav-item.active {
  background: var(--teal-50);
  color: var(--teal-700);
  border: 1px solid var(--teal-100);
}
.nav-item .ico {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  color: var(--slate-500);
  flex-shrink: 0;
}
.nav-item.active .ico { color: var(--teal-600); }
.nav-item .badge {
  margin-left: auto;
  background: var(--teal-100); color: var(--teal-700);
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700;
}
.nav-item .badge.amber { background: var(--warning-50); color: var(--warning-700); }
.nav-item .badge.red   { background: var(--danger-50);  color: var(--danger-700); }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-300), var(--blue-500));
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.user-meta { line-height: 1.2; min-width: 0; }
.user-meta .name { font-weight: 700; font-size: 0.9rem; color: var(--slate-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .role { font-size: 0.78rem; color: var(--text-soft); }

/* Topbar */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--slate-800);
}
.topbar .crumb { color: var(--text-soft); font-weight: 500; }
.topbar .search {
  position: relative;
  flex: 1; max-width: 480px;
  margin-left: 18px;
}
.topbar .search input {
  padding-left: 38px;
  background: var(--slate-50);
  border-color: var(--border);
}
.topbar .search .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-soft);
}
.topbar .actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--slate-50);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--slate-600);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--slate-100); color: var(--teal-600); }
.icon-btn .ping {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger-500);
  border: 2px solid var(--surface);
}

/* Main */
.main {
  grid-area: main;
  padding: 26px 28px 60px;
  min-width: 0;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 16px; margin-bottom: 22px;
}
.page-header h1 { font-size: 1.7rem; margin: 0 0 4px; }
.page-header .sub { color: var(--text-muted); margin: 0; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.kpi .icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--teal-50);
  color: var(--teal-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800;
  flex-shrink: 0;
}
.kpi.blue  .icon { background: var(--blue-50);    color: var(--blue-600); }
.kpi.amber .icon { background: var(--warning-50); color: var(--warning-700); }
.kpi.green .icon { background: var(--success-50); color: var(--success-700); }
.kpi .v { font-size: 1.6rem; font-weight: 800; color: var(--slate-900); letter-spacing: -0.01em; line-height: 1.1; }
.kpi .l { color: var(--text-muted); font-size: 0.86rem; font-weight: 600; }

/* Panels (cards used in dashboard) */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1.05rem; }
.panel-header .actions { display: flex; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-12-8 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left; padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.93rem;
}
.table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  font-weight: 700;
  background: var(--slate-50);
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--slate-50); }

/* List items */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.list-row:hover { background: var(--surface); border-color: var(--teal-200); }
.list-row .meta { flex: 1; min-width: 0; }
.list-row .meta .t { font-weight: 700; color: var(--slate-800); }
.list-row .meta .s { color: var(--text-muted); font-size: 0.86rem; }

/* ============================================================
   Call Assistant Page — the core workflow screen
   ============================================================ */
.call-shell {
  display: grid;
  grid-template-columns: 1.05fr 1.2fr;
  gap: 18px;
  align-items: stretch;
}

.call-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--teal-600), var(--teal-500));
  color: #fff;
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.call-bar .pulse {
  width: 12px; height: 12px; border-radius: 50%;
  background: #FFD78A;
  box-shadow: 0 0 0 0 rgba(255, 215, 138, 0.6);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 215, 138, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(255, 215, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 215, 138, 0); }
}
.call-bar .status { font-weight: 700; }
.call-bar .timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 6px 12px; background: rgba(255,255,255,0.18); border-radius: 999px; }
.call-bar .who { margin-left: 4px; opacity: 0.92; }
.call-bar .who strong { color: #fff; }
.call-bar .right { margin-left: auto; display: flex; gap: 10px; }
.call-bar .btn-secondary { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); color: #fff; }
.call-bar .btn-secondary:hover { background: rgba(255,255,255,0.22); }
.call-bar .btn-danger { background: #fff; color: var(--danger-700); }

.call-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex; flex-direction: column;
}
.call-panel h3 { font-size: 1.05rem; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.call-panel h3 .step-num {
  width: 24px; height: 24px;
  border-radius: 8px;
  background: var(--teal-500); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 800;
}

/* Call type chips (big, easy to click) */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--slate-700);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  user-select: none;
}
.chip:hover { border-color: var(--teal-300); background: var(--teal-50); color: var(--teal-700); }
.chip.active { background: var(--teal-500); color: #fff; border-color: var(--teal-500); box-shadow: 0 4px 10px rgba(44, 122, 123, 0.25); }
.chip .ico { font-size: 1.05rem; }

/* AI Suggestion card */
.ai-suggestion {
  border: 1px solid var(--teal-200);
  background: linear-gradient(180deg, #FCFFFE 0%, #F1FAF9 100%);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
}
.ai-suggestion .ai-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.74rem; font-weight: 700;
  color: var(--teal-600); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.ai-suggestion .ai-label .badge { background: var(--teal-500); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; }
.ai-suggestion .response-text {
  font-size: 1rem;
  color: var(--slate-800);
  line-height: 1.6;
  background: var(--surface);
  border: 1px dashed var(--teal-200);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.ai-suggestion .sources {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px;
}
.source-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--teal-100);
  color: var(--teal-700);
  padding: 5px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
}
.source-chip:hover { background: var(--teal-50); }
.source-chip .doc-ico {
  width: 14px; height: 14px; border-radius: 3px;
  background: var(--teal-100); color: var(--teal-700);
  display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800;
}
.confidence {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--text-muted);
  margin-top: 10px;
}
.confidence .bar { flex: 1; max-width: 160px; height: 6px; background: var(--slate-200); border-radius: 999px; overflow: hidden; }
.confidence .bar > span { display: block; height: 100%; background: var(--success-500); }

/* Workflow output items */
.workflow-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface-2);
  margin-bottom: 10px;
}
.workflow-item .head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.workflow-item .head .ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--teal-50); color: var(--teal-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.workflow-item .head .title { font-weight: 700; color: var(--slate-800); }
.workflow-item .body { color: var(--slate-700); font-size: 0.94rem; }
.workflow-item .actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.workflow-item .actions .btn { padding: 7px 12px; font-size: 0.82rem; }

/* Escalation banner */
.escalate-flag {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--warning-50);
  border: 1px solid #FCE4B5;
  color: var(--warning-700);
  font-weight: 600;
  margin-bottom: 12px;
}
.escalate-flag .ico {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--warning-500); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}

/* Tasks list */
.task-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.task-row:last-child { border-bottom: none; }
.task-row .check {
  width: 24px; height: 24px; border-radius: 6px;
  border: 2px solid var(--border-strong); background: #fff;
  cursor: pointer;
}
.task-row.done .check { background: var(--success-500); border-color: var(--success-500); position: relative; }
.task-row.done .check::after { content: "✓"; color: #fff; font-weight: 800; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.task-row .info .t { font-weight: 700; color: var(--slate-800); }
.task-row.done .info .t { text-decoration: line-through; color: var(--text-soft); }
.task-row .info .s { color: var(--text-muted); font-size: 0.86rem; }

/* Files list */
.file-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto auto;
  gap: 14px; align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
}
.file-row .ext {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--blue-50); color: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.72rem;
}
.file-row .info .t { font-weight: 700; color: var(--slate-800); }
.file-row .info .s { color: var(--text-muted); font-size: 0.84rem; }

/* Uploader */
.uploader {
  border: 2px dashed var(--teal-200);
  background: var(--teal-50);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  color: var(--teal-700);
  cursor: pointer;
}
.uploader:hover { background: var(--teal-100); }
.uploader .ico { font-size: 28px; margin-bottom: 6px; }
.uploader strong { display: block; color: var(--teal-700); }
.uploader span { color: var(--text-muted); font-size: 0.9rem; }

/* Auth (login) */
body.auth {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 30px;
  background:
    radial-gradient(700px 400px at 100% 0%, rgba(62, 189, 176, 0.18), transparent 60%),
    radial-gradient(600px 400px at 0% 100%, rgba(74, 111, 165, 0.12), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-card .brand .logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
  color: #fff; font-weight: 800; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(44, 122, 123, 0.3);
}
.auth-card .brand .label { font-weight: 800; color: var(--slate-800); }
.auth-card .brand .label small { display: block; color: var(--text-soft); font-weight: 600; font-size: 0.78rem; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 24px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 18px; font-size: 0.88rem; }
.auth-row label { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.auth-card .alt { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 0.9rem; }

/* Responsive app */
@media (max-width: 980px) {
  body.app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .call-shell { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-12-8 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .main { padding: 18px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .chip-grid { grid-template-columns: repeat(2, 1fr); }
}
