/* ==========================================================================
   PREMIUM MEDICAL GUIDE AI — Design System
   Identity: a clinical instrument, not a marketing page. Ink-navy + a single
   controlled teal accent (evokes anatomical diagram overlays / vitals
   monitors), a serif for editorial content (essays, notes, book pages) paired
   with a precise grotesk for UI chrome, and a mono face for metadata
   (page refs, difficulty, learning objectives) — like specimen labels.
   Signature motif: a thin pulse/ECG line used as a structural divider.
   ========================================================================== */

:root {
  /* --- Palette --- */
  --ink-900: #101826;      /* primary text, headers */
  --ink-700: #29384d;
  --ink-500: #56677f;      /* secondary text */
  --ink-300: #9aa8ba;      /* placeholders, disabled */
  --line: #dde3ea;         /* hairline borders */
  --surface: #ffffff;
  --surface-sunken: #f5f7fa;
  --canvas: #eef1f5;       /* app background */

  --teal-700: #0b5f66;
  --teal-600: #0f7c86;     /* primary accent */
  --teal-500: #159aa6;
  --teal-100: #e2f3f4;

  --coral-600: #c1443a;    /* alerts / delete / difficulty:hard */
  --coral-100: #fbe9e7;
  --amber-600: #b3791d;    /* difficulty:medium */
  --amber-100: #fbf1de;
  --green-600: #2f7d4f;    /* difficulty:easy / success */
  --green-100: #e6f4ec;

  /* --- Dark mode overrides (applied via [data-theme="dark"]) --- */
  --shadow-sm: 0 1px 2px rgba(16, 24, 38, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 38, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 38, 0.14);

  /* --- Type --- */
  --font-display: 'Source Serif 4', 'Georgia', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-w: 240px;
}

[data-theme="dark"] {
  --ink-900: #eef1f5;
  --ink-700: #cfd8e3;
  --ink-500: #93a2b8;
  --ink-300: #55647a;
  --line: #2a3547;
  --surface: #16202f;
  --surface-sunken: #101826;
  --canvas: #0c121c;
  --teal-100: #103b3d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--canvas);
  color: var(--ink-900);
  font-family: var(--font-ui);
  font-size: var(--base-font-size, 15px);
  -webkit-font-smoothing: antialiased;
}

body.font-small { --base-font-size: 13px; }
body.font-medium { --base-font-size: 15px; }
body.font-large { --base-font-size: 17px; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--ink-900);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}

h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

p { line-height: 1.6; color: var(--ink-700); }

code, .mono { font-family: var(--font-mono); }

a { color: var(--teal-600); text-decoration: none; }

::selection { background: var(--teal-100); }

/* --- Signature motif: pulse-line divider ---
   A thin ECG-style trace used as a section divider. Static by default
   (never distracts from study content); the dashboard header uses a
   gentle one-time draw-in animation, respecting reduced-motion. */
.pulse-divider {
  width: 100%;
  height: 20px;
  display: block;
  color: var(--teal-500);
  opacity: 0.55;
}
.pulse-divider path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (prefers-reduced-motion: no-preference) {
  .pulse-divider.animate path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: draw-pulse 1.1s ease-out forwards;
  }
}
@keyframes draw-pulse {
  to { stroke-dashoffset: 0; }
}

/* --- App shell layout --- */
#app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#sidebar .brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px 18px;
}
#sidebar .brand .mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  color: var(--teal-700);
}
#sidebar .brand .sub {
  font-size: 11px;
  color: var(--ink-500);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-700);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface-sunken); }
.nav-item.active { background: var(--teal-100); color: var(--teal-700); }
.nav-item .icon { font-size: 15px; width: 18px; text-align: center; }

#main-view {
    overflow-y: auto;
    padding: 0;
    width: 100%;
    height: 100vh;
}

.view-header {
  margin-bottom: 22px;
}
.view-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-600);
  margin-bottom: 6px;
}
.view-header p.lede {
  max-width: 640px;
  color: var(--ink-500);
  margin-top: 6px;
}

/* --- Status bar / model banner --- */
.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
}
.status-banner.ok { background: var(--green-100); border-color: transparent; color: var(--green-600); }
.status-banner.warn { background: var(--coral-100); border-color: transparent; color: var(--coral-600); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }



/* =========================================
   LOGIN FULLSCREEN MODE
========================================= */

body.login-mode #app-shell {
    display: grid;
    grid-template-columns: 1fr;
    width: 100vw;
    height: 100vh;
}


body.login-mode #sidebar {
    display: none;
}


body.login-mode #main-view {
    width: 100vw;
    height: 100vh;
    padding: 0;
    overflow: hidden;
}

/* ============================================================
   PREMIUM MEDICAL GUIDE AI
   ADMINISTRATION / CONTENT MANAGER
   ============================================================ */

.admin-section {
    margin: 0 28px 28px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.admin-section-header h2 {
    margin-top: 4px;
}

.admin-section-header button,
.cms-toolbar button {
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 16px;
    background: var(--teal-600);
    color: white;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease;
}

.admin-section-header button:hover,
.cms-toolbar button:hover {
    background: var(--teal-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.admin-section-header button:active,
.cms-toolbar button:active {
    transform: translateY(0);
}


/* ============================================================
   PENDING USER REQUESTS
   ============================================================ */

.pending-users-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pending-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.pending-user-card:hover {
    border-color: var(--teal-500);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.pending-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.pending-user-info strong {
    color: var(--ink-900);
    font-size: 15px;
    font-weight: 650;
}

.pending-user-info span {
    color: var(--ink-500);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pending-user-info small {
    margin-top: 3px;
    color: var(--ink-300);
    font-family: var(--font-mono);
    font-size: 10px;
}

.pending-user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.pending-role {
    min-width: 115px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-700);
    font-family: var(--font-ui);
    font-size: 13px;
    cursor: pointer;
}

.pending-role:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px var(--teal-100);
}

.approve-user-btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 15px;
    background: var(--teal-600);
    color: white;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

.approve-user-btn:hover {
    background: var(--teal-700);
    transform: translateY(-1px);
}

.approve-user-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}


/* ============================================================
   EMPTY / LOADING STATES
   ============================================================ */

.cms-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    padding: 20px;
    color: var(--ink-500);
    background: var(--surface-sunken);
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    font-size: 13px;
    text-align: center;
}


/* ============================================================
   CONTENT MANAGER HEADER
   ============================================================ */

.admin-section > .view-header {
    margin-bottom: 20px;
}

.admin-section > .view-header h2 {
    margin-bottom: 4px;
}

.admin-section > .view-header .lede {
    margin-bottom: 0;
}


/* ============================================================
   CMS TOOLBAR
   ============================================================ */

.cms-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.cms-toolbar-left,
.cms-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cms-toolbar select,
.cms-toolbar input {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-700);
    font-family: var(--font-ui);
    font-size: 13px;
}

.cms-toolbar select {
    padding: 0 32px 0 11px;
}

.cms-toolbar input {
    width: 240px;
    padding: 0 12px;
}

.cms-toolbar input::placeholder {
    color: var(--ink-300);
}

.cms-toolbar select:focus,
.cms-toolbar input:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px var(--teal-100);
}


/* ============================================================
   CMS MAIN LAYOUT
   ============================================================ */

.cms-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 440px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.cms-sidebar {
    min-width: 0;
    border-right: 1px solid var(--line);
    background: var(--surface-sunken);
}

.cms-sidebar-header {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-500);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#cmsSlideList {
    max-height: 440px;
    overflow-y: auto;
}

.cms-preview {
    min-width: 0;
    background: var(--surface);
}

.cms-preview-header {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-500);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#cmsPreview {
    min-height: 390px;
    padding: 20px;
}


/* ============================================================
   RESPONSIVE ADMIN LAYOUT
   ============================================================ */

@media (max-width: 900px) {

    .admin-section {
        margin-left: 18px;
        margin-right: 18px;
        padding: 18px;
    }

    .pending-user-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .pending-user-actions {
        width: 100%;
    }

    .pending-role {
        flex: 1;
    }

    .approve-user-btn {
        flex-shrink: 0;
    }

    .cms-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .cms-toolbar-left,
    .cms-toolbar-right {
        width: 100%;
    }

    .cms-toolbar input {
        flex: 1;
        width: auto;
    }

}

@media (max-width: 700px) {

    .admin-section {
        margin: 12px;
        padding: 14px;
    }

    .admin-section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .cms-layout {
        grid-template-columns: 1fr;
    }

    .cms-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    #cmsSlideList {
        max-height: 220px;
    }

}