/* =====================================================================
   ASM ERP SOFTWARES - Design Tokens
   Subject: clinical / hospital operations software used by reception,
   pharmacists, doctors and administrators under time pressure.
   Direction: "clinical instrument panel" - precise, calm, legible at a
   glance, with a single signature motif (the pulse line) tying every
   screen back to the hospital domain without leaning on a red cross
   or generic medical-blue cliche.
   ===================================================================== */

:root {
    /* Color */
    --ink:          #101C24;   /* near-black, cool */
    --ink-soft:     #45545F;
    --teal-700:     #0B5C55;   /* primary - deep clinical teal */
    --teal-600:     #0E7268;
    --teal-500:     #13897C;
    --teal-100:     #E3F2EF;
    --amber-500:    #F2A65A;   /* attention / pending */
    --coral-500:    #E2604F;   /* danger / critical */
    --moss-500:     #3FAE7E;   /* success / positive */
    --surface:      #F5F8F7;
    --surface-raised: #FFFFFF;
    --border:       #DEE6E4;

    --font-display: "Space Grotesk", "Segoe UI", sans-serif;
    --font-body:    "Inter", "Segoe UI", sans-serif;
    --font-mono:    "JetBrains Mono", "Consolas", monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16,28,36,0.06), 0 1px 1px rgba(16,28,36,0.04);
    --shadow-md: 0 8px 24px rgba(16,28,36,0.08);
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;

    --bg: var(--surface);
    --card-bg: var(--surface-raised);
    --text: var(--ink);
    --text-muted: var(--ink-soft);
    --border-color: var(--border);
}

[data-theme="dark"] {
    --bg: #0B1420;
    --card-bg: #101E2C;
    --text: #E7EEF0;
    --text-muted: #93A5AE;
    --border-color: #1E2E3B;
    --teal-100: #123430;
    --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .display {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
    color: var(--text);
}

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

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

/* ---------------------------------------------------------------------
   Signature motif: the pulse line - a thin animated ECG trace used
   sparingly as a divider under the topbar and on the login screen.
   --------------------------------------------------------------------- */
.pulse-line {
    width: 100%;
    height: 22px;
    overflow: hidden;
    opacity: 0.55;
}
.pulse-line svg { width: 200%; height: 100%; animation: pulse-scroll 6s linear infinite; }
[data-theme="dark"] .pulse-line { opacity: 0.4; }
@keyframes pulse-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
    .pulse-line svg { animation: none; }
}

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width .18s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    flex-shrink: 0;
}
.app-shell.collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-brand .mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: white !important;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-family: var(--font-display); font-weight: 700; flex-shrink: 0;
}
.sidebar-brand .name { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.15; }
.sidebar-brand .name small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 14px 12px 6px; }
.app-shell.collapsed .sidebar-section, .app-shell.collapsed .nav-label { display: none; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 13.5px; font-weight: 500;
    cursor: pointer; white-space: nowrap; overflow: hidden;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item:hover { background: var(--teal-100); color: var(--teal-700); }
.nav-item.active { background: var(--teal-700); color: #fff; }

/* Main column */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 22px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 30;
}
.topbar .toggle-btn { border: none; background: transparent; font-size: 18px; color: var(--text-muted); cursor: pointer; }
.topbar .search-box { flex: 1; max-width: 420px; position: relative; }
.topbar .search-box input {
    width: 100%; padding: 8px 12px 8px 34px; border-radius: 999px;
    border: 1px solid var(--border-color); background: var(--bg); color: var(--text); font-size: 13px;
}
.topbar .search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-icon-btn { position: relative; background: transparent; border: none; color: var(--text-muted); font-size: 17px; cursor: pointer; }
.badge-dot { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--coral-500); }

.dropdown-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 10px);
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-md); min-width: 190px;
    padding: 6px; z-index: 50;
}
.dropdown-menu a {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
    font-size: 13px; color: var(--text);
}
.dropdown-menu a:hover { background: var(--teal-100); color: var(--teal-700); }
.dropdown-menu.open { display: block; }

.profile-chip { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--teal-600); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.profile-chip .who { line-height: 1.1; }
.profile-chip .who .n { font-size: 13px; font-weight: 600; }
.profile-chip .who .r { font-size: 11px; color: var(--text-muted); }
.profile-chip{
    display:flex;
    align-items:center;
    gap:12px;
    cursor:pointer;
}

.dropdown-menu{
    position:absolute;
    top:110%;
    right:0;
    min-width:210px;
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:10px;
    box-shadow:0 12px 30px rgba(0,0,0,.12);
    display:none;
    z-index:9999;
    overflow:hidden;
}

.dropdown-menu.show{
    display:block;
}

.dropdown-menu a,
.dropdown-menu .dropdown-btn{
    width:100%;
    display:flex;
    align-items:center;
    gap:10px;
    padding:12px 16px;
    color:#1f2937;
    text-decoration:none;
    border:0;
    background:none;
    cursor:pointer;
    font-size:14px;
}

.dropdown-menu a:hover,
.dropdown-menu .dropdown-btn:hover{
    background:#f5f5f5;
}
.content { padding: 22px; flex: 1; }

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }

.stat-card { display: flex; flex-direction: column; gap: 10px; padding: 18px 18px; }
.stat-card .icon-wrap {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.stat-card .value { font-family: var(--font-display); font-size: 26px; font-weight: 600; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); }
.stat-card .trend { font-size: 11.5px; font-weight: 600; }
.trend.up { color: var(--moss-500); }
.trend.down { color: var(--coral-500); }
.trend.warn { color: var(--amber-500); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }

.section-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 0 0 2px; }
.section-sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px; }

.charts-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.charts-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .charts-grid, .charts-grid-2 { grid-template-columns: 1fr; } }

.notif-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border-color); }
.notif-item:last-child { border-bottom: none; }
.notif-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal-500); margin-top: 6px; flex-shrink: 0; }
.notif-item .t { font-size: 13px; }
.notif-item .m { font-size: 11px; color: var(--text-muted); }

/* Buttons */
.btn { border: none; border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--teal-700); color: #fff; }
.btn-primary:hover { background: var(--teal-600); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border-color); }

/* Toasts */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    min-width: 260px; background: var(--card-bg); border: 1px solid var(--border-color);
    border-left: 4px solid var(--teal-600); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); padding: 12px 14px; font-size: 13px;
    animation: toast-in .2s ease;
}
.toast.error { border-left-color: var(--coral-500); }
.toast.success { border-left-color: var(--moss-500); }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 860px) {
    .sidebar { position: fixed; left: -280px; height: 100vh; box-shadow: var(--shadow-md); }
    .app-shell.mobile-open .sidebar { left: 0; }
    .content { padding: 14px; }
}
