/* ===================================================
   KARTIKA-MCU : Rumkit Tk II Putri Hijau Kesdam I/BB
   Universal Hospital Design System
   =================================================== */

:root {
    --sidebar-bg: #0E172A;
    --sidebar-hover: #1E293B;
    --sidebar-active: #0F5B35;
    --sidebar-width: 260px;
    --header-height: 66px;
    --primary-green: #0F5B35;
    --primary-green-light: #198754;
    --primary-green-dark: #093c23;
    --text-navy: #17324D;
    --text-muted: #64748B;
    --body-bg: #F5F7FA;
    --card-bg: #FFFFFF;
    --border-color: #E2E8F0;
    --danger-red: #DC2626;
    --warning-yellow: #D97706;
    --info-blue: #0284C7;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
}

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

body.app-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-navy);
    font-size: 14px;
    line-height: 1.5;
}

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

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: #F8FAFC;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid #1E293B;
    gap: 0.75rem;
}

.brand-crest {
    font-size: 1.6rem;
    display: flex;
    align-items: center;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #FFFFFF;
    line-height: 1.1;
}

.brand-unit {
    font-size: 0.65rem;
    color: #94A3B8;
    display: block;
    font-weight: 700;
}

.brand-sub {
    font-size: 0.6rem;
    color: #22C55E;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.sidebar-user {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #1E293B;
    background: rgba(255,255,255,0.02);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-green);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-meta .user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #F1F5F9;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 800;
    color: #64748B;
    letter-spacing: 1px;
    padding: 0.75rem 0.6rem 0.35rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    color: #94A3B8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #FFFFFF;
}

.nav-link.active {
    background: var(--primary-green);
    color: #FFFFFF;
    font-weight: 600;
}

.nav-pill {
    margin-left: auto;
    background: #22C55E;
    color: #052e16;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 9999px;
}

.nav-link-logout {
    color: #F87171;
}

.nav-link-logout:hover {
    background: #450A0A;
    color: #FCA5A5;
}

/* App Main & Header */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-header {
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.btn-sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    color: var(--text-navy);
}

.header-titles {
    flex: 1;
}

.header-main-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-navy);
    letter-spacing: 0.2px;
}

.header-sub-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    background: #F1F5F9;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
}

/* Badges */
.badge-role-admin {
    background: #DCFCE7;
    color: #15803D;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-role-petugas {
    background: #E0E7FF;
    color: #4338CA;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-role-user {
    background: #FEF3C7;
    color: #B45309;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Main Content */
.app-content {
    flex: 1;
    padding: 1.75rem;
}

/* Footer */
.app-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 0.85rem 1.75rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Common UI Elements */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-navy);
}

.card-body {
    padding: 1.25rem;
}

/* Dashboard Statistics Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.stat-card-inner .stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.stat-card-inner .stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-navy);
    margin: 0.25rem 0;
}

.stat-card-inner .stat-sub {
    font-size: 0.72rem;
    color: var(--primary-green-light);
    font-weight: 600;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.icon-blue { background: #E0F2FE; color: #0369A1; }
.icon-green { background: #DCFCE7; color: #15803D; }
.icon-yellow { background: #FEF3C7; color: #B45309; }
.icon-purple { background: #F3E8FF; color: #7E22CE; }

/* Grid 2 Columns for Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-primary {
    background: var(--primary-green);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-green-light);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-navy);
}
.btn-outline:hover {
    background: #F1F5F9;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

.btn-success { background: #16A34A; color: #fff; }
.btn-danger { background: #DC2626; color: #fff; }
.btn-warning { background: #D97706; color: #fff; }

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.table th, .table td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.table th {
    background: #F8FAFC;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
}

.table tr:hover {
    background: #F8FAFC;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-completed, .badge-normal, .badge-active { background: #DCFCE7; color: #166534; }
.badge-registered, .badge-pending { background: #FEF3C7; color: #92400E; }
.badge-examination, .badge-follow_up { background: #E0F2FE; color: #075985; }
.badge-cancelled, .badge-abnormal, .badge-inactive { background: #FEE2E2; color: #991B1B; }
/* PERBAIKAN: status "confirmed" (pendaftaran online) belum punya style,
   sehingga badge tampil polos tanpa warna. */
.badge-confirmed { background: #DBEAFE; color: #1D4ED8; }

/* Form Controls */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-navy);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: #fff;
    color: var(--text-navy);
    outline: none;
    transition: border 0.15s ease;
}

.form-control:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 2px rgba(15, 91, 53, 0.15);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.alert-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #86EFAC; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }

/* Filter Bar */
.filter-bar {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.filter-form .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

/* Patient auto info panel */
.patient-found-box {
    background: #ECFDF5;
    border: 1px solid #A7F3D0;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .btn-sidebar-toggle {
        display: inline-block;
    }
    /* PERBAIKAN: sebelumnya tidak ada overlay/backdrop saat sidebar mobile
       dibuka, sehingga area konten di belakangnya tetap bisa diklik/di-scroll
       dan pengguna tidak punya cara mudah menutup sidebar selain tombol toggle. */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(14, 23, 42, 0.5);
        z-index: 99;
    }
    .sidebar-overlay.show {
        display: block;
    }
}
