/* ============================================================
   Mater Dei EMS - Updated Theme (Light Blue + White + Golden)
   ============================================================ */

:root {
    --primary: #4A90D9;
    --primary-light: #6BA8E8;
    --primary-dark: #2D6FA8;
    --primary-gradient: linear-gradient(135deg, #4A90D9 0%, #2D6FA8 100%);
    --accent: #C9A84C;
    --accent-light: #E0C86A;
    --accent-dark: #A8892E;
    --bg: #FFFFFF;
    --bg-light: #F8F9FA;
    --card-bg: #FFFFFF;
    --text: #1E1E2A;
    --text-light: #5A6A7A;
    --text-muted: #8A9BAE;
    --border: #E2E8F0;
    --shadow: 0 8px 32px rgba(74, 144, 217, 0.10);
    --shadow-hover: 0 12px 48px rgba(74, 144, 217, 0.18);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s cubic-bezier(0.4,0,0.2,1);
    --sidebar-width: 260px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Playfair Display', serif;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-light);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   LOGIN PAGE – Light blue gradient background
   ============================================================ */
#loginPage {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4A90D9 0%, #2D6FA8 50%, #1A4A7A 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
#loginPage::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(201, 168, 76, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}
#loginPage::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(74, 144, 217, 0.10) 0%, transparent 70%);
    border-radius: 50%;
}

.login-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 460px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 48px 40px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: fadeUp 0.6s ease-out;
}
@keyframes fadeUp {
    from { opacity:0; transform:translateY(30px); }
    to { opacity:1; transform:translateY(0); }
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand .logo-icon {
    font-size: 42px;
    color: var(--accent);
    margin-bottom: 6px;
}
.login-brand h1 {
    font-family: var(--font-display);
    font-size: 26px;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}
.login-brand h1 span {
    color: var(--accent);
}
.login-brand p {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 18px;
}
.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}
.login-form label i {
    margin-right: 6px;
    color: var(--accent);
    width: 18px;
}
.login-form input,
.login-form select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    transition: var(--transition);
    background: var(--bg);
    color: var(--text);
}
.login-form input:focus,
.login-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.15);
    background: #fff;
}
.login-form select {
    appearance: none;
    cursor: pointer;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 6px;
}
.login-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(74, 144, 217, 0.25);
}

.login-error {
    background: #FEE2E2;
    color: #B91C1C;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border-left: 4px solid #B91C1C;
    display: block;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 18px;
}
.demo-creds {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
}
.demo-creds .cred-badge {
    background: var(--bg-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.demo-creds .cred-badge:hover {
    border-color: var(--accent);
    background: #fff;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
    display: flex;
    width: 100%;
    min-height: 100vh;
    background: var(--bg-light);
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-dark);
    color: #fff;
    min-height: 100vh;
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
}
.sidebar-brand {
    padding: 0 24px 28px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 16px;
}
.sidebar-brand .brand-icon {
    font-size: 28px;
    color: var(--accent);
}
.sidebar-brand h2 {
    font-family: var(--font-display);
    font-size: 18px;
    margin-top: 2px;
    letter-spacing: -0.3px;
}
.sidebar-brand h2 span {
    color: var(--accent);
}
.sidebar-brand .sub {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 2px;
}
.sidebar-nav a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: rgba(255,255,255,0.4);
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}
.sidebar-nav a:hover i {
    color: var(--accent);
}
.sidebar-nav a.active {
    background: rgba(201, 168, 76, 0.15);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav a.active i {
    color: var(--accent);
}

.sidebar-footer {
    padding: 16px 24px 0 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 8px;
}
.sidebar-footer .user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05);
}
.sidebar-footer .user-badge .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary-dark);
    overflow: hidden;
}
.sidebar-footer .user-badge .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.sidebar-footer .user-badge .info {
    flex: 1;
    min-width: 0;
}
.sidebar-footer .user-badge .info .name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-footer .user-badge .info .role {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    text-transform: capitalize;
}
.sidebar-footer .logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin-top: 10px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.6);
    border: none;
    width: 100%;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
    text-decoration: none;
}
.sidebar-footer .logout-btn:hover {
    background: rgba(255,70,70,0.15);
    color: #ff8a8a;
}
.sidebar-footer .logout-btn i {
    font-size: 15px;
}

.main-content {
    flex: 1;
    padding: 28px 36px 40px 36px;
    overflow-y: auto;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-left .menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}
.topbar-left h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.topbar-left h1 small {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-light);
    margin-left: 6px;
}
.topbar-right .date-badge {
    font-size: 13px;
    color: var(--text-light);
    background: var(--card-bg);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-weight: 500;
}
.topbar-right .date-badge i {
    margin-right: 6px;
    color: var(--accent);
}

.page-section {
    display: none;
    animation: fadeUp 0.35s ease-out;
}
.page-section.active {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 22px 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}
.stat-card .stat-icon {
    font-size: 28px;
    color: var(--accent);
    margin-bottom: 6px;
}
.stat-card .stat-number {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -1px;
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}
.stat-card.stat-primary .stat-icon { color: var(--primary); }
.stat-card.stat-accent .stat-icon { color: var(--accent); }
.stat-card.stat-green .stat-icon { color: #2b8a3e; }
.stat-card.stat-purple .stat-icon { color: #6c3cb0; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}
.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.card-header h3 {
    font-size: 17px;
    font-weight: 700;
}
.card-header h3 i {
    color: var(--accent);
    margin-right: 8px;
}
.card-body {
    padding: 20px 24px;
}

.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table thead {
    background: var(--bg-light);
}
table th {
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}
table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table tbody tr:hover {
    background: rgba(74, 144, 217, 0.04);
}

.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-light);
    color: var(--text-light);
}
.badge-accent {
    background: #F0E6C8;
    color: #7A621E;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(74, 144, 217, 0.2);
}
.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.3);
}
.btn-outline {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-danger {
    background: #DC3545;
    color: #fff;
}
.btn-danger:hover {
    background: #C82333;
}
.btn-xs {
    padding: 2px 10px;
    font-size: 11px;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.mb-12 {
    margin-bottom: 12px;
}
.text-center {
    text-align: center;
}
.text-muted {
    color: var(--text-muted);
}
.w-full {
    width: 100%;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}
.modal-overlay.active {
    display: flex;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}
.modal-header h3 i {
    color: var(--accent);
    margin-right: 8px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 0 4px;
}
.modal-close:hover {
    color: var(--text);
    transform: rotate(90deg);
}
.modal-body {
    padding: 24px;
}
.modal-body .form-group {
    margin-bottom: 16px;
}
.modal-body label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}
.modal-body label i {
    color: var(--accent);
    margin-right: 6px;
    width: 18px;
}
.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
    background: var(--bg);
}
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.12);
    background: #fff;
}
.modal-body textarea {
    resize: vertical;
    min-height: 70px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    width: 100%;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    animation: slideInRight 0.4s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}
.toast-success { background: #1A7A3A; }
.toast-error { background: #B91C1C; }
.toast-info { background: var(--primary); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 280px;
        height: 100vh;
        z-index: 200;
        box-shadow: 4px 0 30px rgba(0,0,0,0.2);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 150;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .topbar-left .menu-toggle {
        display: block;
    }
    .main-content {
        padding: 20px;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 576px) {
    .login-container {
        padding: 32px 20px;
    }
    .main-content {
        padding: 14px;
    }
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }
    .card-body {
        padding: 14px;
    }
    table {
        font-size: 13px;
    }
    table th,
    table td {
        padding: 8px 10px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .modal {
        margin: 10px;
    }
    .topbar-left h1 {
        font-size: 18px;
    }
    .topbar-right .date-badge {
        font-size: 11px;
        padding: 4px 12px;
    }
}