/* ============================================================
   app.css — Dr. SaHaab Diagnostics Internal Platform
   Design system: clean medical/clinical aesthetic
   Colors: Navy (#1a3a5c), Blue (#0d6efd), clean neutrals
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────── */
:root {
  --primary:       #0d6efd;
  --primary-dark:  #1a3a5c;
  --primary-soft:  #dbeafe;
  --secondary:     #475569;
  --secondary-soft:#f1f5f9;
  --accent:        #0ea5e9;
  --success:       #22c55e;
  --success-soft:  #dcfce7;
  --warning:       #f59e0b;
  --warning-soft:  #fef9c3;
  --danger:        #ef4444;
  --danger-soft:   #fee2e2;
  --info:          #06b6d4;
  --info-soft:     #cffafe;
  --neutral-50:    #f8fafc;
  --neutral-100:   #f1f5f9;
  --neutral-200:   #e2e8f0;
  --neutral-300:   #cbd5e1;
  --neutral-400:   #94a3b8;
  --neutral-600:   #475569;
  --neutral-800:   #1e293b;
  --neutral-900:   #0f172a;
  --sidebar-w:     260px;
  --sidebar-w-collapsed: 0px;
  --topbar-h:      60px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:        0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);
  --font-body:     'Inter', system-ui, sans-serif;
  --font-display:  'Playfair Display', Georgia, serif;
  --transition:    0.2s ease;
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--neutral-800);
  background: var(--neutral-50);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neutral-400); }

/* ══════════════════════════════════════════════════════════
   AUTH PAGES
   ══════════════════════════════════════════════════════════ */
.auth-body {
  background: var(--primary-dark);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-container { width: 100%; max-width: 900px; }

.auth-card {
  display: flex;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-height: 560px;
}

.auth-left {
  background: linear-gradient(160deg, #1a3a5c 0%, #0d6efd 100%);
  width: 45%;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

.auth-brand { position: relative; z-index: 2; }

.auth-logo {
  height: 60px;
  margin-bottom: 16px;
  filter: brightness(0) invert(1);
}

.auth-brand-name {
  font-family: var(--font-display);
  font-size: 28px;
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 8px;
}

.auth-brand-tagline {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  line-height: 1.6;
}

.auth-decorations { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.deco-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.deco-c1 { width: 200px; height: 200px; bottom: -60px; right: -60px; }
.deco-c2 { width: 120px; height: 120px; top: 40px; right: 30px; }
.deco-c3 { width: 60px;  height: 60px;  top: 160px; right: 80px; background: rgba(255,255,255,0.1); }

.auth-right {
  flex: 1;
  padding: 48px 40px;
  display: flex;
  align-items: center;
}

.auth-form-container { width: 100%; max-width: 360px; }

.auth-title    { font-size: 26px; font-weight: 700; color: var(--neutral-900); margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--neutral-400); margin-bottom: 28px; }

.input-group-auth .input-group-text {
  background: var(--neutral-50);
  border-color: var(--neutral-200);
  color: var(--neutral-400);
}
.input-group-auth .form-control { border-color: var(--neutral-200); background: var(--neutral-50); }
.input-group-auth .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.1);
  background: #fff;
}

.btn-auth {
  height: 46px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  letter-spacing: 0.3px;
}

.auth-footer-text {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--neutral-400);
}

/* ══════════════════════════════════════════════════════════
   LAYOUT: SIDEBAR + MAIN
   ══════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform var(--transition);
}

.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}
.main-wrapper.sidebar-collapsed { margin-left: 0; }

/* ── Sidebar Brand ──────────────────────────────────────── */
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-logo { display: flex; align-items: center; gap: 12px; }
.brand-logo img { height: 40px; filter: brightness(0) invert(1); }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 0.2px; }
.brand-sub  { font-size: 11px; color: rgba(255,255,255,0.5); }

/* ── Sidebar Nav ────────────────────────────────────────── */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav .nav { padding: 0 10px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.65);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.sidebar-nav .nav-link i { font-size: 16px; width: 20px; flex-shrink: 0; }
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13,110,253,0.4);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  padding: 12px 14px 4px;
}

/* ── Sidebar Footer ─────────────────────────────────────── */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary);
  color: #fff; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }
.btn-logout {
  color: rgba(255,255,255,0.5);
  font-size: 18px;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--danger); }

/* ── Top Bar ────────────────────────────────────────────── */
.top-bar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  background: none;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--neutral-600);
  cursor: pointer; transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--neutral-100); }

.current-date { font-size: 13px; color: var(--neutral-400); }

/* ── Page Content ───────────────────────────────────────── */
.page-content { padding: 28px 28px 40px; flex: 1; }

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--neutral-900);
  margin: 0 0 4px;
}
.page-subtitle { font-size: 13px; color: var(--neutral-400); margin: 0; }

/* ══════════════════════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════════════════════ */

/* ── Card Panel ─────────────────────────────────────────── */
.card-panel {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--neutral-200);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-title { font-size: 15px; font-weight: 600; color: var(--neutral-800); margin: 0; }
.section-title { font-size: 14px; font-weight: 600; color: var(--neutral-700); margin: 0 0 14px; }

/* ── Stat Cards ─────────────────────────────────────────── */
.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 700; color: var(--neutral-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--neutral-400); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Soft color helpers */
.bg-primary-soft   { background: var(--primary-soft); }
.bg-success-soft   { background: var(--success-soft); }
.bg-warning-soft   { background: var(--warning-soft); }
.bg-danger-soft    { background: var(--danger-soft); }
.bg-info-soft      { background: var(--info-soft); }
.bg-secondary-soft { background: var(--secondary-soft); }
.text-primary   { color: var(--primary) !important; }
.text-success   { color: var(--success) !important; }
.text-warning   { color: var(--warning) !important; }
.text-danger    { color: var(--danger) !important; }
.text-info      { color: var(--info) !important; }
.text-secondary { color: var(--secondary) !important; }

/* ── Quick Actions ──────────────────────────────────────── */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  color: var(--neutral-700);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  min-width: 110px;
}
.quick-action-card:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.qa-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

/* ── Tables ─────────────────────────────────────────────── */
.table { font-size: 13.5px; }
.table th { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--neutral-400); border-bottom-width: 1px; background: var(--neutral-50); }
.table td { vertical-align: middle; color: var(--neutral-700); }
.table-hover tbody tr:hover { background: var(--neutral-50); }

/* ── Empty State ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--neutral-400); }
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { margin: 0; font-size: 14px; }
.empty-state-icon i { font-size: 56px; color: var(--neutral-300); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* ── Score Classes ──────────────────────────────────────── */
.score-good    { color: var(--success); }
.score-warning { color: var(--warning); }
.score-danger  { color: var(--danger); }

/* ══════════════════════════════════════════════════════════
   UPLOAD PAGE
   ══════════════════════════════════════════════════════════ */
.drop-zone {
  border: 2px dashed var(--neutral-300);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--neutral-50);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.drop-zone-icon { font-size: 48px; color: var(--neutral-300); margin-bottom: 12px; }
.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon { color: var(--primary); }
.drop-zone-title  { font-size: 17px; font-weight: 600; color: var(--neutral-700); margin: 0 0 4px; }
.drop-zone-sub    { font-size: 13px; color: var(--neutral-400); margin: 0 0 4px; }
.drop-zone-browse { color: var(--primary); cursor: pointer; font-weight: 600; }
.drop-zone-hint   { font-size: 12px; color: var(--neutral-400); margin: 0; }

.selected-file {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.selected-file-info { flex: 1; text-align: left; }
.selected-filename  { display: block; font-weight: 600; color: var(--neutral-800); font-size: 14px; }
.selected-filesize  { font-size: 12px; color: var(--neutral-400); }

.upload-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.upload-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--neutral-200);
  color: var(--neutral-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.step-text { font-size: 11px; color: var(--neutral-400); }
.step-arrow { color: var(--neutral-300); font-size: 16px; }

/* ══════════════════════════════════════════════════════════
   REVIEW PAGE
   ══════════════════════════════════════════════════════════ */

/* ── Workflow Steps ─────────────────────────────────────── */
.workflow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  padding: 14px 20px;
  overflow-x: auto;
}
.wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}
.wf-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--neutral-200);
  color: var(--neutral-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  transition: all var(--transition);
}
.wf-label { font-size: 11px; color: var(--neutral-400); white-space: nowrap; }
.wf-step.active .wf-num  { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.wf-step.done   .wf-num  { background: var(--success); color: #fff; }
.wf-step.done   .wf-label { color: var(--success); }
.wf-line { flex: 1; height: 2px; background: var(--neutral-200); min-width: 24px; margin-top: -14px; }

/* ── Extracted Text ─────────────────────────────────────── */
.extracted-text-scroll {
  max-height: 420px;
  overflow-y: auto;
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}
.extracted-text-content {
  font-family: monospace;
  font-size: 12px;
  color: var(--neutral-600);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* ── Health Score Row ───────────────────────────────────── */
.health-score-row {
  display: flex;
  align-items: center;
  gap: 20px;
}
.health-score-gauge { width: 120px; flex-shrink: 0; position: relative; }
.gauge-svg { width: 120px; }
.gauge-value {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  font-size: 22px; font-weight: 700;
  color: var(--neutral-800);
  line-height: 1;
}
.health-score-info { flex: 1; }
.health-score-input { width: 70px !important; }

/* ── Finding Items ──────────────────────────────────────── */
.finding-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: #fff;
  transition: box-shadow var(--transition);
}
.finding-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.finding-handle { padding-top: 6px; cursor: grab; color: var(--neutral-300); }
.finding-fields { flex: 1; display: grid; grid-template-columns: 2fr 1fr 1fr 2fr; gap: 6px; }

/* ── Tag List ───────────────────────────────────────────── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 32px; }
.tag-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 13px;
}
.tag-text { font-weight: 500; }
.tag-remove {
  background: none; border: none; cursor: pointer;
  color: var(--primary); font-size: 16px; padding: 0;
  line-height: 1; opacity: 0.6;
  transition: opacity var(--transition);
}
.tag-remove:hover { opacity: 1; }

/* ── Autosave Indicator ─────────────────────────────────── */
.autosave-indicator { font-size: 12px; }

/* ══════════════════════════════════════════════════════════
   ADMIN — TEMPLATES
   ══════════════════════════════════════════════════════════ */
.template-card {
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: all var(--transition);
  cursor: pointer;
}
.template-card:hover    { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.template-card.active   { border-color: var(--primary); background: var(--primary-soft); }
.template-card-header   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.template-card-title    { font-weight: 600; font-size: 13.5px; color: var(--neutral-800); }
.template-card-desc     { font-size: 12px; color: var(--neutral-400); margin: 0; }

.token-reference { display: flex; flex-wrap: wrap; gap: 4px; }
.token-badge {
  background: var(--neutral-100);
  border: 1px solid var(--neutral-200);
  color: var(--neutral-600);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
}

.code-editor-wrapper .CodeMirror { height: 500px; font-size: 13px; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 991px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .auth-left { display: none; }
  .auth-card { max-width: 440px; margin: 0 auto; }
  .auth-right { padding: 36px 28px; }
  .finding-fields { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 575px) {
  .page-content { padding: 20px 16px 32px; }
  .page-header  { flex-direction: column; align-items: flex-start; }
  .page-header .btn { width: 100%; }
  .card-panel { padding: 16px; }
  .health-score-row { flex-direction: column; align-items: flex-start; }
  .finding-fields { grid-template-columns: 1fr; }
  .workflow-steps { padding: 10px; }
  .wf-label { display: none; }
}

/* ══════════════════════════════════════════════════════════
   BOOTSTRAP OVERRIDES
   ══════════════════════════════════════════════════════════ */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: all var(--transition);
}
.btn-primary   { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #0b5ed7; border-color: #0b5ed7; box-shadow: 0 2px 8px rgba(13,110,253,0.3); }
.btn-success:hover { box-shadow: 0 2px 8px rgba(34,197,94,0.3); }

.form-control, .form-select {
  border-color: var(--neutral-200);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: all var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.1);
}
.form-label { font-size: 13px; font-weight: 500; color: var(--neutral-700); margin-bottom: 6px; }

.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-header  { background: var(--neutral-50); border-bottom: 1px solid var(--neutral-200); border-radius: var(--radius) var(--radius) 0 0; }

.alert { border-radius: var(--radius-sm); font-size: 13.5px; }

.nav-tabs .nav-link { font-size: 13px; font-weight: 500; color: var(--neutral-600); }
.nav-tabs .nav-link.active { color: var(--primary); font-weight: 600; }

.pagination .page-link { font-size: 13px; border-radius: 6px !important; margin: 0 2px; }
