/* ============================================================
   E-POSYANDU - MEDICAL DASHBOARD STYLES
   Desain modern, minimalis, profesional, dominan hijau lembut.
   ============================================================ */

:root {
    --primary-color: #2E7D32;
    --primary-light: #A5D6A7;
    --primary-dark: #1B5E20;
    --secondary-color: #81C784;
    --bg-color: #F4F7F6;
    --card-bg: #FFFFFF;
    --text-main: #263238;
    --text-muted: #78909C;
    --border-color: #E8ECEF;
    --danger-color: #D32F2F;
    --warning-color: #F57C00;
    --info-color: #0288D1;
    --sidebar-width: 260px;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);

    /* Warna Statistik */
    --stat-blue: #42A5F5;
    --stat-pink: #EC407A;
    --stat-orange: #FF9800;
    --stat-red: #EF5350;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: 14px;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ============ SPLASH SCREEN ============ */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.splash-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: denyut 1.5s ease-in-out infinite;
}

.splash-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 1px;
}

.splash-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 8px;
    font-weight: 300;
}

.splash-loader {
    margin-top: 30px;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: putar 1s linear infinite;
}

@keyframes denyut {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes putar {
    to { transform: rotate(360deg); }
}

/* ============ UTILITAS ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger-color); }
.text-muted { color: var(--text-muted); }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }
.ml-2 { margin-left: 10px; }
.gap-2 { gap: 10px; }
.mb-3 { margin-bottom: 15px; }

/* ============ BUTTONS ============ */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #ECEFF1; color: var(--text-main); }
.btn-secondary:hover { background: #E0E5E8; }

.btn-danger { background: var(--danger-color); color: white; }
.btn-danger:hover { background: #B71C1C; }

.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon:hover { color: var(--primary-color); background: #E8F5E9; }
.btn-icon.text-danger:hover { color: var(--danger-color); background: #FFEBEE; }

/* ============ FORM ============ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.25s;
    background: white;
    color: var(--text-main);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

.form-control:read-only {
    background: #F5F7F8;
    color: var(--text-muted);
}

.form-control-sm { padding: 7px 10px; font-size: 13px; }

.grid-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-group {
    position: relative;
}

.input-group i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.input-group .form-control { padding-left: 40px; }

/* ============ ALERT ============ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-danger { background: #FFEBEE; color: #C62828; border: 1px solid #FFCDD2; }
.alert-warning { background: #FFF8E1; color: #F57C00; border: 1px solid #FFE082; }
.alert-success { background: #E8F5E9; color: #2E7D32; border: 1px solid #C8E6C9; }
.alert-info { background: #E1F5FE; color: #0277BD; border: 1px solid #B3E5FC; }

/* ============ CARD ============ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.card-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h4 { font-size: 16px; font-weight: 600; }

.card-body { position: relative; }

/* ============ LOGIN PAGE ============ */
.login-page {
    display: flex;
    min-height: 100vh;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 50%, #A5D6A7 100%);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container { width: 100%; max-width: 420px; }

.login-box {
    padding: 40px 36px;
    text-align: center;
    border-radius: 16px;
}

/* Label & form di login dibuat rata kiri (kecuali header/login-logo yang tetap tengah) */
.login-box .form-group {
    text-align: left;
}

.login-box .form-group label {
    text-align: left;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    margin: 0 auto 16px;
    box-shadow: 0 6px 20px rgba(46, 125, 50, 0.3);
}

.login-header h2 { font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.login-header p { color: var(--text-muted); font-size: 13px; margin-top: 4px; margin-bottom: 24px; }

.login-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

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

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .sidebar-close { margin-left: auto; display: none; }

.user-info {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    flex-shrink: 0;
}

.avatar-lg { width: 64px; height: 64px; font-size: 28px; }

.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--text-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }

.nav-header {
    padding: 12px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-link i { width: 20px; text-align: center; color: var(--text-muted); transition: color 0.2s; }

.nav-link:hover { background: #F5F9F5; color: var(--primary-dark); }
.nav-link:hover i { color: var(--primary-color); }

.nav-link.active {
    background: #E8F5E9;
    color: var(--primary-dark);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.nav-link.active i { color: var(--primary-color); }

/* Tombol Keluar berwarna merah */
#btn-logout {
    color: var(--danger-color);
}

#btn-logout i {
    color: var(--danger-color);
}

#btn-logout:hover {
    background: #FFEBEE;
    color: var(--danger-color);
}

#btn-logout:hover i {
    color: var(--danger-color);
}

.nav-spacer { margin-top: 16px; border-top: 1px solid var(--border-color); padding-top: 8px; }

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.topbar {
    height: 65px;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h3 { font-size: 18px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #FFF8E1;
    color: #F57C00;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #FFE082;
}

.offline-alert {
    background: #FFEBEE;
    color: #C62828;
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #FFCDD2;
}

.content-wrapper { padding: 24px; flex: 1; overflow-y: auto; }

/* ============ BADGE ============ */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.badge-success { background: var(--primary-color); }
.badge-danger { background: var(--danger-color); }
.badge-warning { background: var(--warning-color); }
.badge-primary { background: var(--info-color); }
.badge-secondary { background: #90A4AE; }

/* ============ GRID & STAT ============ */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card { display: flex; align-items: center; gap: 16px; transition: all 0.3s; }
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
}

.bg-blue { background: var(--stat-blue); }
.bg-pink { background: var(--stat-pink); }
.bg-orange { background: var(--stat-orange); }
.bg-red { background: var(--stat-red); }

.stat-details h3 { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-number { font-size: 26px; font-weight: 700; color: var(--text-main); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

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

.table { width: 100%; border-collapse: collapse; }

.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.table th {
    background: #FAFBFC;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.table tbody tr { transition: background 0.2s; }
.table tbody tr:hover { background: #F8FAF8; }

/* ============ CHART ============ */
.chart-wrapper { height: 320px; position: relative; }

/* ============ MODAL ============ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active { display: flex; animation: munculModal 0.25s ease; }

@keyframes munculModal {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 14px;
    width: 100%;
    max-width: 540px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-lg { max-width: 900px; }
.modal-content.modal-sm { max-width: 420px; }

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    border-radius: 14px 14px 0 0;
    z-index: 1;
}

.modal-header h4 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 22px; }

/* ============ PROFILE ============ */
.profile-info { display: flex; align-items: center; gap: 16px; }
.profile-info h3 { font-size: 18px; font-weight: 600; }
.profile-info p { color: var(--text-muted); font-size: 13px; }

hr { border: none; border-top: 1px solid var(--border-color); }

/* ============ FILTER BAR ============ */
.filter-bar { display: flex; gap: 10px; min-width: 180px; }

/* ============ TOAST ============ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 18px;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    animation: slideMasuk 0.3s ease;
    max-width: 360px;
}

.toast-sukses { background: var(--primary-color); }
.toast-error { background: var(--danger-color); }
.toast-peringatan { background: var(--warning-color); }
.toast-info { background: var(--info-color); }

.toast-hilang { opacity: 0; transition: opacity 0.4s; }

@keyframes slideMasuk {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============ RESPONSIVE ============ */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 900;
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar-header .sidebar-close { display: block; }

    .mobile-only { display: block; }
    .grid-form { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }

    .content-wrapper { padding: 16px; }

    .topbar { padding: 0 16px; gap: 10px; }
    .topbar .btn-sm { display: none; }

    .grid-cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
    .stat-number { font-size: 20px; }
    .stat-icon { width: 44px; height: 44px; font-size: 20px; }

    .card { padding: 16px; }

    #toast-container { top: 10px; right: 10px; left: 10px; }
    .toast { max-width: none; }
}

@media (max-width: 480px) {
    .grid-cards { grid-template-columns: 1fr 1fr; }
    .login-box { padding: 30px 22px; }
}
