/* ===== ROOT VARIABLES ===== */
:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --primary-light: #E3F2FD;
    --accent: #F57C00;
    --success: #2E7D32;
    --danger: #C62828;
    --warning: #F9A825;
    --bg: #F0F4F8;
    --card-bg: #FFFFFF;
    --text: #1A237E;
    --text-muted: #78909C;
    --border: #CFD8DC;
    --nav-height: 64px;
    --header-height: 56px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: #263238;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
}

/* ===== MOBILE ONLY WRAPPER ===== */
.app-wrapper {
    max-width: 430px;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0 auto;
    background: var(--bg);
    position: relative;
}

/* Shadow dipindah ke pseudo-element agar tidak repaint saat scroll */
.app-wrapper::before,
.app-wrapper::after {
    content: '';
    position: fixed;
    top: 0;
    bottom: 0;
    width: 40px;
    pointer-events: none;
    z-index: 1;
}
.app-wrapper::before {
    left: 50%;
    transform: translateX(-430px);
    box-shadow: inset 12px 0 24px -12px rgba(0,0,0,0.12);
}
.app-wrapper::after {
    left: 50%;
    transform: translateX(390px);
    box-shadow: inset -12px 0 24px -12px rgba(0,0,0,0.12);
}

/* ===== HEADER ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    height: var(--header-height);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    will-change: transform;
    transform: translateX(-50%) translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.app-header .header-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
    flex: 1;
    text-align: center;
}

.app-header .header-back,
.app-header .header-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    background: rgba(255,255,255,0.15);
    color: white;
    text-decoration: none;
    border: none;
    font-size: 16px;
    transition: background 0.2s;
}

.app-header .header-action:hover { background: rgba(255,255,255,0.25); }

.notif-badge {
    position: relative;
    display: inline-block;
}

.notif-badge .badge-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #FF5252;
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid var(--primary);
}

/* ===== CONTENT AREA ===== */
.app-content {
    padding-top: calc(var(--header-height) + 12px);
    padding-bottom: calc(var(--nav-height) + 16px);
    min-height: 100vh;
    padding-left: 12px;
    padding-right: 12px;
}

.app-content.no-nav {
    padding-bottom: 20px;
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateZ(0);
    width: 100%;
    max-width: 430px;
    height: var(--nav-height);
    background: white;
    display: flex;
    align-items: stretch;
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    gap: 3px;
    transition: color 0.2s;
    padding: 4px 2px;
}

.nav-item i {
    font-size: 20px;
    line-height: 1;
}

.nav-item.active {
    color: var(--primary);
    font-weight: 600;
}

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

/* ===== CARDS ===== */
.app-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    border: none;
}

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

.app-card .card-header-custom h6 {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    margin: 0;
}

/* ===== STAT CARDS ===== */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card.full-width {
    grid-column: 1 / -1;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 18px;
}

.stat-card .stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #263238;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ===== HERO CARD ===== */
.hero-card {
    background: linear-gradient(135deg, var(--primary), #1976D2);
    border-radius: var(--radius);
    padding: 20px;
    color: white;
    box-shadow: 0 4px 16px rgba(21,101,192,0.35);
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}

.hero-card::after {
    content: '';
    position: absolute;
    right: -30px;
    top: -30px;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}

.hero-card .hero-label {
    font-size: 12px;
    opacity: 0.85;
    margin-bottom: 4px;
}

.hero-card .hero-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.hero-card .hero-meta {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    gap: 16px;
}

/* ===== LIST ITEMS ===== */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #F5F5F5;
    text-decoration: none;
    color: inherit;
}

.list-item:last-child { border-bottom: none; }

.list-item .item-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.list-item .item-body {
    flex: 1;
    min-width: 0;
}

.list-item .item-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item .item-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.list-item .item-right {
    text-align: right;
    flex-shrink: 0;
}

.list-item .item-amount {
    font-weight: 700;
    font-size: 14px;
    color: var(--success);
}

/* ===== FORMS ===== */
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #455A64;
    margin-bottom: 5px;
}

.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    background: white;
    color: #263238;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
    outline: none;
}

.form-group { margin-bottom: 14px; }

/* ===== BUTTONS ===== */
.btn {
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(21,101,192,0.3);
}

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

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 2px 8px rgba(46,125,50,0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 8px rgba(198,40,40,0.3);
}

.btn-warning {
    background: var(--warning);
    color: #263238;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.btn-secondary {
    background: #ECEFF1;
    color: #546E7A;
}

.btn-block { width: 100%; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-lg {
    padding: 14px 20px;
    font-size: 15px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.bg-warning { background: #FFF8E1 !important; color: #F57F17 !important; }
.bg-success { background: #E8F5E9 !important; color: #2E7D32 !important; }
.bg-danger { background: #FFEBEE !important; color: #C62828 !important; }
.bg-primary { background: #E3F2FD !important; color: #1565C0 !important; }
.bg-info { background: #E0F7FA !important; color: #00838F !important; }
.bg-secondary { background: #ECEFF1 !important; color: #546E7A !important; }

/* ===== ALERTS ===== */
.alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: none;
}

.alert-success { background: #E8F5E9; color: #2E7D32; }
.alert-danger { background: #FFEBEE; color: #C62828; }
.alert-warning { background: #FFF8E1; color: #F57F17; }
.alert-info { background: #E3F2FD; color: #1565C0; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--primary) 0%, #1976D2 40%, var(--bg) 100%);
    padding: 24px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo img {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.login-logo .app-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 10px;
    display: block;
}

.login-logo .app-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== PROGRESS TABUNGAN ===== */
.progress-bar-custom {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-custom .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #42A5F5);
    border-radius: 4px;
    transition: width 0.5s;
}

/* ===== WEEK GRID ===== */
.week-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    margin: 8px 0;
}

.week-dot {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--border);
    position: relative;
}

.week-dot.paid { background: var(--success); }
.week-dot.pending { background: var(--warning); }
.week-dot.current { background: var(--primary); box-shadow: 0 0 0 2px white, 0 0 0 3px var(--primary); }

/* ===== FILE UPLOAD ===== */
.file-upload-box {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #FAFAFA;
    position: relative;
}

.file-upload-box:hover { border-color: var(--primary); background: var(--primary-light); }
.file-upload-box input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-upload-box .upload-icon { font-size: 28px; color: var(--text-muted); margin-bottom: 6px; }
.file-upload-box .upload-text { font-size: 13px; color: var(--text-muted); }
.file-upload-box .file-preview { max-width: 100%; max-height: 120px; border-radius: 6px; margin-top: 8px; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-sheet {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 430px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}

/* ===== TABS ===== */
.app-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 12px;
}

.app-tab {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
}

.app-tab.active {
    background: white;
    color: var(--primary);
    font-weight: 700;
    box-shadow: var(--shadow);
}

/* ===== TABLE ===== */
.app-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.app-table th {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    padding: 10px 8px;
    text-align: left;
    border-bottom: 2px solid var(--primary);
}

.app-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #F5F5F5;
    vertical-align: middle;
}

.app-table tbody tr:hover { background: #FAFAFA; }

/* ===== DIVIDER ===== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    margin-top: 4px;
}

/* ===== CHIP/TAG ===== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
    margin: 2px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.4; display: block; }
.empty-state p { font-size: 14px; }

/* ===== NOTIF PAGE ===== */
.notif-item {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid #F5F5F5;
}

.notif-item.unread { background: var(--primary-light); margin: 0 -16px; padding: 12px 16px; }
.notif-item .notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }
.notif-item .notif-body .notif-title { font-weight: 600; font-size: 13px; }
.notif-item .notif-body .notif-text { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-item .notif-body .notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== CHECKBOX NASABAH ===== */
.nasabah-check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.nasabah-check-item:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
}

.nasabah-check-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* ===== STICKY FOOTER BTN ===== */
.sticky-btn {
    position: sticky;
    bottom: calc(var(--nav-height) + 8px);
    z-index: 50;
    margin: 12px 0;
}

/* ===== SETUP/INSTALL PAGE ===== */
.setup-header {
    background: linear-gradient(135deg, var(--primary), #1976D2);
    color: white;
    padding: 32px 20px 20px;
    text-align: center;
}

.setup-step {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.setup-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ===== PRINT ===== */
@media print {
    .bottom-nav, .app-header, .btn, .no-print { display: none !important; }
    .app-content { padding: 0 !important; }
    .app-wrapper { box-shadow: none; max-width: none; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
