/* ============================================================
   BlueLotus Healthcare - Design System
   Blue/White clinical trust theme with glassmorphism
============================================================ */
:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    --primary-50: #F0F7FF;
    --primary-100: #DBEAFE;
    --primary-600: #2563EB;
    --primary-700: #1D4ED8;
    --primary-800: #1E40AF;

    --app-bg: #F1F5FB;
    --sidebar-bg: #FFFFFF;
    --glass: rgba(255, 255, 255, 0.82);
    --glass-strong: rgba(255, 255, 255, 0.95);
    --border: #E2E8F0;
    --border-light: #EEF2F7;

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;

    --emergency: #EF4444;
    --recovery: #10B981;
    --warning: #F59E0B;
    --info: #3B82F6;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 16px rgba(37, 99, 235, 0.06);
    --shadow-lg: 0 12px 40px rgba(37, 99, 235, 0.08);
    --shadow-glow: 0 0 0 4px rgba(37, 99, 235, 0.10);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 999px;

    --sidebar-w: 260px;
    --topbar-h: 72px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    color: var(--text-primary);
    background: var(--app-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    font-family: 'Manrope', system-ui, sans-serif;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

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

/* ============================================================
   App Shell
============================================================ */
.app-body {
    background:
        radial-gradient(1200px 600px at -10% -20%, #DDEBFF 0%, transparent 55%),
        radial-gradient(900px 500px at 110% 10%, #E8F0FF 0%, transparent 60%),
        var(--app-bg);
    min-height: 100vh;
}

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

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

.app-content {
    padding: 32px 40px 48px;
}

/* ============================================================
   Sidebar
============================================================ */
.app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-light);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 0 20px rgba(15, 23, 42, 0.03);
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary) !important;
}

.brand-dot {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563EB 0%, #60A5FA 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
    position: relative;
    flex-shrink: 0;
}
.brand-dot::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 2px solid #fff;
    border-radius: 6px;
    border-bottom: none;
    border-right: none;
    transform: rotate(-45deg);
}

.brand-text strong {
    display: block;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.02em;
}
.brand-text small { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: background-color 0.15s ease, color 0.15s ease;
    position: relative;
}
.side-link i { width: 18px; text-align: center; font-size: 14px; color: var(--text-muted); }
.side-link:hover { background: var(--primary-50); color: var(--primary-700); }
.side-link:hover i { color: var(--primary-700); }
.side-link.active {
    background: linear-gradient(135deg, rgba(37,99,235,0.10), rgba(96,165,250,0.10));
    color: var(--primary-700);
    font-weight: 600;
}
.side-link.active i { color: var(--primary-700); }
.side-link.active::before {
    content: '';
    position: absolute; left: 0; top: 8px; bottom: 8px;
    width: 3px; border-radius: 2px;
    background: var(--primary);
}

.side-footer { border-top: 1px solid var(--border-light); padding-top: 16px; }
.side-role-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary-700);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 10px;
}
.side-logout {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-secondary); font-size: 13px; font-weight: 500;
    padding: 10px 14px; border-radius: var(--radius-md);
    transition: background-color 0.15s;
}
.side-logout:hover { background: #FEE2E2; color: var(--emergency); }

/* ============================================================
   Topbar
============================================================ */
.app-topbar {
    height: var(--topbar-h);
    padding: 0 40px;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-light);
    position: sticky; top: 0; z-index: 30;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-crumb { color: var(--text-muted); font-size: 12px; margin: 2px 0 0; text-transform: uppercase; letter-spacing: 0.14em; }

.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-btn {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--border-light);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    transition: color 0.15s, border-color 0.15s;
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); }
.notif-dot {
    position: absolute; top: -6px; right: -6px;
    background: var(--emergency); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: var(--radius-full);
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 6px rgba(239,68,68,0.4);
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, #2563EB, #60A5FA);
    color: #fff; font-weight: 700; font-family: 'Manrope', sans-serif;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.topbar-user-meta strong { display: block; font-size: 14px; }
.topbar-user-meta small { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }

/* ============================================================
   Glass Cards
============================================================ */
.g-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
}
.g-card-strong { background: var(--glass-strong); }

.g-card h3, .g-card h4 { margin-top: 0; }

/* KPI cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.kpi {
    background: var(--glass-strong);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    position: relative;
    overflow: hidden;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi::before {
    content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: linear-gradient(90deg, var(--kpi-color, var(--primary)), transparent);
}
.kpi-icon {
    width: 52px; height: 52px; border-radius: 14px;
    background: var(--kpi-bg, var(--primary-light));
    color: var(--kpi-color, var(--primary));
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.kpi-meta small { color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.kpi-meta .kpi-value { font-family: 'Manrope', sans-serif; font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1.1; margin-top: 4px; }

.kpi.k-patients { --kpi-color: #2563EB; --kpi-bg: #DBEAFE; }
.kpi.k-appts    { --kpi-color: #7C3AED; --kpi-bg: #EDE9FE; }
.kpi.k-admitted { --kpi-color: #0891B2; --kpi-bg: #CFFAFE; }
.kpi.k-doctors  { --kpi-color: #059669; --kpi-bg: #D1FAE5; }
.kpi.k-emergency{ --kpi-color: #EF4444; --kpi-bg: #FEE2E2; }

/* ============================================================
   Grid layouts
============================================================ */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
@media (max-width: 992px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Section title */
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title h3 { font-size: 16px; font-weight: 700; margin: 0; }
.section-title small { color: var(--text-muted); font-size: 12px; }

/* Chart canvas wrapper */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.small { height: 220px; }

/* ============================================================
   Tables
============================================================ */
.tbl-wrap {
    background: var(--glass-strong);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.tbl thead th {
    background: #F8FAFF;
    color: var(--text-muted);
    text-align: left;
    padding: 14px 18px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    border-bottom: 1px solid var(--border-light);
}
.tbl tbody td {
    padding: 14px 18px;
    border-top: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}
.tbl tbody tr:hover { background: rgba(219, 234, 254, 0.4); }
.tbl-actions { display: flex; gap: 6px; }

.avatar-mini {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #93C5FD, #2563EB);
    color: #fff; font-weight: 700; font-size: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.name-cell { display: flex; align-items: center; gap: 10px; }
.name-cell strong { display: block; color: var(--text-primary); }
.name-cell small { color: var(--text-muted); font-size: 11.5px; }

/* Status pills */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    font-size: 11px; font-weight: 600;
    border-radius: var(--radius-full);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.pill-active     { background: #D1FAE5; color: #065F46; }
.pill-admitted   { background: #DBEAFE; color: #1E40AF; }
.pill-discharged { background: #E0E7FF; color: #3730A3; }
.pill-deceased   { background: #FEE2E2; color: #991B1B; }
.pill-scheduled  { background: #DBEAFE; color: #1E40AF; }
.pill-completed  { background: #D1FAE5; color: #065F46; }
.pill-cancelled  { background: #FEE2E2; color: #991B1B; }
.pill-rescheduled{ background: #FEF3C7; color: #92400E; }
.pill-noshow     { background: #F1F5F9; color: #475569; }
.pill-info       { background: #E0F2FE; color: #075985; }

/* ============================================================
   Buttons
============================================================ */
.btn { border-radius: var(--radius-full); padding: 10px 22px; font-weight: 600; font-size: 14px; }
.btn-brand { background: var(--primary); color: #fff; border: none; box-shadow: 0 4px 14px rgba(37,99,235,0.28); transition: background-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.btn-brand:hover { background: var(--primary-hover); color: #fff; box-shadow: 0 8px 20px rgba(37,99,235,0.34); transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--primary-700); border: 1px solid var(--primary-100); }
.btn-ghost:hover { background: var(--primary-50); }
.btn-danger { background: var(--emergency); color: #fff; border: none; }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #fff; border: 1px solid var(--border-light);
    color: var(--text-secondary);
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn-icon:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.btn-icon.danger:hover { background: #FEE2E2; color: var(--emergency); border-color: #FECACA; }

/* ============================================================
   Forms
============================================================ */
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.form-control, .form-select, textarea.form-control {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
    outline: none;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }

/* ============================================================
   Flash Messages
============================================================ */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.flash {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
}
.flash i { font-size: 18px; }
.flash-success { border-left: 4px solid var(--recovery); }
.flash-success i { color: var(--recovery); }
.flash-error { border-left: 4px solid var(--emergency); }
.flash-error i { color: var(--emergency); }
.flash-close { background: transparent; border: none; color: var(--text-muted); margin-left: auto; cursor: pointer; }

/* ============================================================
   Auth Layout
============================================================ */
.auth-body {
    background:
        radial-gradient(600px 600px at 10% 10%, #DBEAFE 0%, transparent 60%),
        radial-gradient(700px 500px at 90% 90%, #E0E7FF 0%, transparent 60%),
        #F8FAFF;
    min-height: 100vh;
}
.auth-shell {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    min-height: 100vh;
    padding: 24px;
    gap: 24px;
}
.auth-hero {
    position: relative;
    border-radius: 28px;
    padding: 60px;
    color: #fff;
    background:
        linear-gradient(160deg, rgba(29,78,216,0.9) 0%, rgba(37,99,235,0.86) 50%, rgba(96,165,250,0.8) 100%),
        url('https://images.unsplash.com/photo-1679193559811-b3a3a6353230?crop=entropy&cs=srgb&fm=jpg&q=85') center/cover;
    display: flex; align-items: flex-end;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(29,78,216,0.35);
}
.auth-hero::before {
    content: '';
    position: absolute; inset: 0;
    background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.12), transparent 50%),
                      radial-gradient(circle at 80% 70%, rgba(255,255,255,0.10), transparent 50%);
    pointer-events: none;
}
.auth-hero-inner { position: relative; z-index: 1; max-width: 460px; }
.brand-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.brand-mark .brand-dot { background: #fff; box-shadow: none; }
.brand-mark .brand-dot::after { border-color: var(--primary-700); }
.brand-mark .brand-name { font-family: 'Manrope', sans-serif; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }

.auth-hero-title {
    font-family: 'Manrope', sans-serif;
    font-size: 44px; font-weight: 800;
    line-height: 1.1; letter-spacing: -0.02em;
    color: #fff; margin: 0 0 18px;
}
.auth-hero-sub { font-size: 16px; opacity: 0.9; line-height: 1.5; margin-bottom: 30px; }
.auth-hero-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-hero-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; opacity: 0.92; }
.auth-hero-features i { width: 28px; height: 28px; background: rgba(255,255,255,0.16); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; backdrop-filter: blur(10px); }

.auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 60px;
    max-width: 520px;
    width: 100%;
    justify-self: center;
}

.auth-card { padding: 6px 0; }
.auth-card h2 { font-size: 28px; font-weight: 800; margin: 0 0 6px; }
.auth-card .lead { color: var(--text-secondary); margin-bottom: 32px; font-size: 15px; }
.auth-actions { display: flex; align-items: center; justify-content: space-between; font-size: 13px; margin-top: 8px; }

@media (max-width: 992px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { padding: 40px 30px; min-height: 260px; }
    .auth-hero-title { font-size: 30px; }
    .auth-panel { padding: 20px; }
}

/* ============================================================
   Responsive sidebar
============================================================ */
@media (max-width: 900px) {
    .app-sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 20px; }
    .app-topbar { padding: 0 20px; }
}

/* ============================================================
   Utility
============================================================ */
.muted { color: var(--text-muted); }
.text-tiny { font-size: 12px; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.gap-4 { gap: 16px; }
.mt-3 { margin-top: 16px; }
.mb-3 { margin-bottom: 16px; }

.activity-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.activity-item:last-child { border-bottom: none; }
.activity-item .a-dot { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-light); color: var(--primary-700); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-item .a-body strong { display: block; font-size: 14px; }
.activity-item .a-body small { color: var(--text-muted); font-size: 12px; }

/* Patient hero */
.patient-hero {
    display: grid; grid-template-columns: 120px 1fr auto; gap: 24px; align-items: center;
    padding: 24px; background: var(--glass-strong); border-radius: var(--radius-lg);
    border: 1px solid var(--border-light); box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}
.patient-hero .avatar-lg {
    width: 120px; height: 120px; border-radius: 20px;
    background: linear-gradient(135deg, #DBEAFE, #93C5FD);
    color: var(--primary-700); font-weight: 800; font-family: 'Manrope', sans-serif;
    font-size: 42px;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(37,99,235,0.25);
    background-size: cover; background-position: center;
}
.patient-hero h2 { font-size: 24px; margin: 0 0 4px; }
.patient-hero .patient-meta { color: var(--text-muted); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; }
.patient-hero .patient-meta span { display: flex; align-items: center; gap: 6px; }

.notif-card {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 16px; border-radius: var(--radius-md); background: #fff;
    border: 1px solid var(--border-light); margin-bottom: 10px;
}
.notif-card.unread { border-left: 4px solid var(--primary); background: var(--primary-50); }
.notif-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-light); color: var(--primary-700); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon.critical { background: #FEE2E2; color: #B91C1C; }
.notif-icon.appointment { background: #DBEAFE; color: #1D4ED8; }
.notif-icon.medication { background: #D1FAE5; color: #065F46; }
.notif-icon.emergency { background: #FEE2E2; color: #B91C1C; }
