/* =====================================================================
   Doctors Chamber Management System — Design Tokens
   Palette: deep clinical teal + warm amber accent (deliberately not the
   generic cream/terracotta or near-black/neon AI-template defaults).
   Display: Space Grotesk · Body: Inter · Data/IDs: IBM Plex Mono
   ===================================================================== */

:root {
    --bg: #F4F8F7;
    --surface: #FFFFFF;
    --surface-alt: #EBF2F0;
    --ink: #14302C;
    --muted: #5E7772;
    --primary: #0F5C56;
    --primary-strong: #0A3E3A;
    --primary-soft: #E3F0EC;
    --accent: #E8A33D;
    --accent-strong: #C97F1E;
    --line: #DDE8E5;
    --success: #2F9E63;
    --success-soft: #E4F5EC;
    --danger: #D6534A;
    --danger-soft: #FBE9E7;
    --warning: #E8A33D;
    --warning-soft: #FCF1DE;
    --info: #2E7D9C;
    --info-soft: #E4F1F6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(20, 48, 44, .04), 0 6px 20px rgba(20, 48, 44, .06);
    --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6, .font-display {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.font-mono, .patient-uid, .code-value {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    letter-spacing: -0.01em;
}

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

/* ---------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--primary-strong) 0%, var(--primary) 100%);
    color: #EAF4F1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.3rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-brand .mark {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--primary-strong);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-brand .title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1rem; color: #fff; line-height: 1.15; }
.sidebar-brand .subtitle { font-size: .72rem; color: rgba(234,244,241,.65); letter-spacing: .04em; text-transform: uppercase; }

.sidebar-nav { padding: .9rem .75rem; flex: 1; overflow-y: auto; }
.sidebar-section-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    color: rgba(234,244,241,.45); margin: 1.1rem .6rem .4rem;
    font-weight: 600;
}
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .65rem;
    color: rgba(234,244,241,.82);
    padding: .55rem .65rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i { width: 18px; text-align: center; font-size: .9rem; opacity: .9; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--accent); color: var(--primary-strong); font-weight: 600; }
.sidebar-nav .nav-link.active i { opacity: 1; }

.sidebar-foot { padding: .9rem 1.1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.12); }

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: .85rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
    position: sticky; top: 0; z-index: 30;
}

/* Signature element: a quiet heartbeat trace under the topbar */
.pulse-divider { height: 22px; width: 100%; overflow: hidden; background: var(--bg); }
.pulse-divider svg { width: 100%; height: 100%; display: block; }
.pulse-divider path {
    fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 620; stroke-dashoffset: 620;
    animation: pulse-draw 1.6s ease-out forwards;
}
@media (prefers-reduced-motion: reduce) {
    .pulse-divider path { animation: none; stroke-dashoffset: 0; }
}
@keyframes pulse-draw { to { stroke-dashoffset: 0; } }

.page-content { padding: 1.5rem; flex: 1; }

/* ---------------------------------------------------------------------
   Components
   --------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 1rem 1.25rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}
.card-body { padding: 1.25rem; }

.stat-card { padding: 1.1rem 1.25rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.85rem; font-weight: 700; color: var(--ink); }
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary); font-size: 1.05rem;
}

.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .875rem; padding: .5rem 1rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--primary-strong); }
.btn-accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

.btn:focus-visible, .form-control:focus, .form-select:focus, a:focus-visible, .nav-link:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.badge-status { font-weight: 600; font-size: .72rem; padding: .32em .6em; border-radius: 999px; }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--danger-soft); color: var(--danger); }
.badge-pending { background: var(--warning-soft); color: var(--accent-strong); }
.badge-info { background: var(--info-soft); color: var(--info); }

.table > :not(caption) > * > * { padding: .75rem 1rem; vertical-align: middle; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); background: var(--surface-alt); border-bottom: none; font-weight: 600;
}
.table-hover tbody tr:hover { background: var(--primary-soft); }

.avatar-circle {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; font-family: 'Space Grotesk', sans-serif;
}

.section-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.15rem; margin-bottom: .2rem; }
.section-subtitle { color: var(--muted); font-size: .875rem; }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--muted); }
.empty-state i { font-size: 2rem; color: var(--line); margin-bottom: .75rem; display: block; }

/* Auth page */
.auth-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 20% 20%, #14544E 0%, var(--primary-strong) 45%, #08221F 100%);
    padding: 1.5rem;
}
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 2.25rem 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: var(--primary-strong); display: flex; align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif; font-weight: 700; margin-bottom: 1rem; }

/* Duplicate-check panel on patient registration */
.dup-alert { border: 1px solid var(--warning); background: var(--warning-soft); border-radius: var(--radius-sm); padding: .85rem 1rem; }
.dup-alert .dup-item { font-size: .85rem; padding: .35rem 0; border-bottom: 1px dashed rgba(0,0,0,.08); }
.dup-alert .dup-item:last-child { border-bottom: none; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
}
