:root {
    /* Vivid Ocean & Emerald Palette */
    --primary: #0284c7;        /* vibrant blue */
    --primary-light: #38bdf8;
    --primary-dark: #0369a1;
    --secondary: #10b981;      /* emerald green */
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --border: rgba(255, 255, 255, 0.4);
    
    /* Semantic */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Upgraded Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 10px 40px -10px rgba(0, 50, 100, 0.15);
    
    --font-sans: 'Inter', system-ui, sans-serif;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Animated Mesh Gradient Background */
    background: radial-gradient(at 0% 0%, hsla(199,100%,85%,1) 0px, transparent 50%),
                radial-gradient(at 100% 0%, hsla(168,100%,88%,1) 0px, transparent 50%),
                radial-gradient(at 100% 100%, hsla(213,100%,88%,1) 0px, transparent 50%),
                radial-gradient(at 0% 100%, hsla(186,100%,88%,1) 0px, transparent 50%);
    background-color: #f0f9ff;
    background-attachment: fixed;
}

/* Animations */
@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(20px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.animate-slide-up { animation: slideUpFade var(--transition-normal) forwards; }
.animate-fade-in { animation: fadeIn var(--transition-normal) forwards; }

/* Structural Layout: Sidebar + Main */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: fixed;
    height: 100vh;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,0.03);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.6);
    color: var(--primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.main-content {
    flex: 1;
    margin-left: 260px; /* offset for sidebar */
    padding: 2rem 3rem;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    
    /* Mobile Top Navbar (Sleek Apple style) */
    .sidebar { 
        width: 100%; height: auto; position: sticky; top: 0; z-index: 100;
        padding: 0.75rem 1rem; flex-direction: row; flex-wrap: nowrap; 
        justify-content: space-between; align-items: center; 
        border-right: none; border-bottom: 1px solid var(--border); 
        box-shadow: 0 4px 12px rgba(0,0,0,0.05); 
    }
    .sidebar-nav { display: none; }
    .sidebar-header { flex: none; }
    .sidebar-header div { font-size: 1.25rem !important; font-weight: 800; letter-spacing: -0.5px; }
    
    /* Minimalist Profile/Logout on Mobile */
    .sidebar-footer { padding: 0; border: none; display: flex; align-items: center; gap: 1rem; flex-direction: row; }
    .sidebar-footer .flex-col { display: none; } /* Hide user text */
    .sidebar-footer .avatar { width: 36px; height: 36px; font-size: 1rem !important; }
    .sidebar-footer #btn-logout { 
        width: auto !important; padding: 0.5rem !important; margin: 0; 
        background: transparent !important; border: none !important; 
        color: var(--danger) !important; box-shadow: none !important; 
    }
    .sidebar-footer #btn-logout:hover { background: rgba(239, 68, 68, 0.1) !important; }
    
    .main-content { margin-left: 0; padding: 1.25rem 1rem 5rem 1rem; }
    
    /* Dashboard Page Header fixing */
    .main-content > .flex-row.justify-between.items-center:first-child { 
        flex-direction: column !important; align-items: flex-start !important; gap: 1.5rem !important; 
    }
    .main-content > .flex-row > div:first-child h1 { font-size: 1.75rem !important; line-height: 1.1; margin-bottom: 0.2rem; }
    .main-content > .flex-row > div:first-child p { font-size: 0.85rem !important; }
    
    /* Action Buttons Array */
    .main-content > .flex-row > div:last-child { 
        width: 100%; display: flex; flex-direction: row; 
    }
    #btn-add-patient-header { display: none !important; } /* Hidden because FAB covers adding patients on mobile */
    #btn-view-patients { width: 100% !important; justify-content: center !important; }
    
    .dashboard-grid { margin-top: 1rem; gap: 1rem; }
    .stat-value { font-size: 2rem; }
    .analytic-card .flex-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .analytic-card .roster-card { width: 100%; box-sizing: border-box; }
    
    .dash-content-grid { gap: 1.5rem; margin-top: 1.5rem; }
    .list-item { flex-direction: column; align-items: stretch; gap: 1rem; }
    .list-item > div:first-child .flex-col { display: block; overflow-wrap: anywhere; }
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    transition: var(--transition-normal);
}

.glass-card:hover {
    box-shadow: 0 12px 48px -12px rgba(0, 50, 100, 0.2);
}

/* Base Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

.btn-outline {
    background: rgba(255,255,255, 0.8);
    border: 1px solid var(--border);
    color: var(--text-main);
}
.btn-outline:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Inputs */
.input-group { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.input-group label { font-size: 0.875rem; font-weight: 600; color: var(--text-muted); }
.input-control {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.8);
    font-family: var(--font-sans);
    font-size: 1rem;
    transition: all var(--transition-fast);
}
.input-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.15); background: #ffffff; }
textarea.input-control { min-height: 100px; resize: vertical; }

/* Dashboard Grids */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}
@media (min-width: 1024px) {
    .dashboard-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Special Colorful Analytics Cards */
.analytic-card { position: relative; overflow: hidden; color: white; border: none; }
.analytic-emerald { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3); }
.analytic-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3); }
.analytic-rose { background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 8px 24px rgba(244, 63, 94, 0.3); }

.analytic-card .stat-icon { background: rgba(255,255,255,0.2); color: white; }
.analytic-card .text-muted { color: rgba(255,255,255,0.8); }
.analytic-card .stat-value { color: white; }

.stat-card-header { display: flex; align-items: center; justify-content: space-between; }
.stat-icon { width: 48px; height: 48px; border-radius: 1rem; background: rgba(2, 132, 199, 0.1); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.stat-value { font-size: 2.5rem; font-weight: 800; line-height: 1.2; margin-top: 0.5rem; }

/* Dashboard Dual Column Layout */
.dash-content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-top: 3rem;
}
@media (min-width: 1200px) {
    .dash-content-grid { grid-template-columns: 2fr 1fr; }
}

/* Avatars & Badges */
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem; color: white;
}
.ward-badge {
    padding: 0.25rem 0.5rem; border-radius: 0.5rem;
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    background: #e0f2fe; color: #0284c7;
}

/* List Items */
.list-group { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.list-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem; border-radius: 1rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
    cursor: pointer;
}
.list-item:hover { background: #ffffff; transform: translateY(-3px); box-shadow: 0 8px 16px rgba(0,0,0,0.05); border-color: var(--primary-light); }

.patient-status-badge { padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;}
.status-live { background: #d1fae5; color: #047857; }
.status-discharged { background: #e0f2fe; color: #0369a1; }
.status-died { background: #fee2e2; color: #b91c1c; }

/* Pin Star */
.pin-star {
    color: #cbd5e1;
    transition: var(--transition-fast);
}
.pin-star:hover { color: #f59e0b; }
.pin-star.fixed { color: #f59e0b; fill: #f59e0b; }

/* Activity Feed */
.feed-item {
    position: relative;
    padding-left: 24px;
    padding-bottom: 1.5rem;
}
.feed-item::before { content: ''; position: absolute; left: 6px; top: 24px; bottom: 0; width: 2px; background: var(--border); }
.feed-item:last-child::before { display: none; }
.feed-dot { position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px rgba(2,132,199,0.2); }
.feed-dot.emerald { background: var(--success); }
.feed-dot.rose { background: var(--danger); }
.feed-dot.indigo { background: #6366f1; }

.feed-time { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; margin-bottom: 0.25rem; }
.feed-msg { font-size: 0.9rem; color: var(--text-main); }
.feed-msg b { color: var(--primary-dark); }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; opacity: 0; pointer-events: none;
    transition: opacity var(--transition-normal);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content {
    width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto;
    background: rgba(255,255,255,0.95);
    border-radius: 1.5rem; padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.95);
    transition: all var(--transition-normal);
}
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.close-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.5rem; border-radius: 0.5rem; transition: 0.2s;}
.close-btn:hover { background: #fee2e2; color: var(--danger); }

/* Timeline (Patient Details) */
.timeline { position: relative; padding-left: 2rem; margin-top: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: 0.5rem; top: 0; bottom: 0; width: 2px; background: rgba(2, 132, 199, 0.2); }
.timeline-item { position: relative; padding-bottom: 2rem; }
.timeline-dot { position: absolute; left: -2.3rem; top: 0.25rem; width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 3px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.timeline-content { background: white; border: 1px solid var(--border); border-radius: 1rem; padding: 1.5rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }

/* Utilities */
.text-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-primary { color: var(--primary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 1rem; }
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }

/* Login View Adjustments */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 420px; text-align: center; padding: 3rem 2rem; }

/* Tabs */
.tabs { display: flex; gap: 1rem; border-bottom: 2px solid var(--border); margin-bottom: 2rem; }
.tab-btn { padding: 0.75rem 0; background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; font-size: 1rem; color: var(--text-muted); cursor: pointer; transition: var(--transition-fast); }
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.fab {
    position: fixed; bottom: 2rem; right: 2rem; width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.5); cursor: pointer; transition: all var(--transition-fast); z-index: 40;
}
.fab:hover { transform: scale(1.05) translateY(-5px); box-shadow: 0 15px 35px -5px rgba(2, 132, 199, 0.6); }

/* --- Admin Panel & Full Upgrade Styles --- */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 1024px) {
    .admin-grid { grid-template-columns: 1fr 1fr; }
}

.table-container { overflow-x: auto; margin-top: 1rem; border-radius: 0.75rem; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; text-align: left; background: rgba(255,255,255,0.5); }
table th { background: rgba(0,0,0,0.05); padding: 1rem; font-weight: 700; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
table td { padding: 1rem; border-top: 1px solid var(--border); color: var(--text-main); font-weight: 500; }
table tr:hover { background: rgba(255,255,255,0.8); }

.profile-img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 3px solid white; box-shadow: 0 4px 12px rgba(0,0,0,0.1); background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; font-weight: bold; }
.roster-card { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; background: rgba(255,255,255,0.15); padding: 1rem; border-radius: 1rem; border: 1px solid rgba(255,255,255,0.3); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; padding: 1rem 1.5rem; }
.filter-bar input, .filter-bar select { flex: 1; min-width: 150px; border: none; background: transparent; padding: 0.5rem; font-size: 1rem; outline: none; border-left: 2px solid var(--border); border-radius: 0; box-shadow: none; }
.filter-bar input:focus, .filter-bar select:focus { box-shadow: none; background: rgba(255,255,255,0.5); }
.filter-bar > :first-child { border-left: none; }

