/* DKM Al-Hidayah - Custom Styles */
:root {
    --primary: #15803d;
    --primary-dark: #166534;
    --primary-light: #dcfce7;
    --primary-lighter: #f0fdf4;
    --accent: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --surface: #ffffff;
    --bg: #f0fdf4;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ====== LAYOUT ====== */
#app { display: flex; flex-direction: column; min-height: 100vh; }
#page-content { flex: 1; padding-bottom: 80px; }

/* ====== TOP BAR ====== */
#topbar {
    background: var(--primary);
    color: white;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
#topbar .logo { display: flex; align-items: center; gap: 10px; }
#topbar .logo-icon { width: 32px; height: 32px; background: rgba(255,255,255,0.2); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
#topbar .logo-text { font-weight: 600; font-size: 15px; line-height: 1.2; }
#topbar .logo-sub { font-size: 11px; opacity: 0.8; }
#topbar .topbar-actions { display: flex; align-items: center; gap: 8px; }
#user-badge { background: rgba(255,255,255,0.15); border-radius: 20px; padding: 4px 12px; font-size: 12px; cursor: pointer; }

/* ====== BOTTOM NAV ====== */
#bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 8px 4px; cursor: pointer;
    color: var(--text-muted); transition: all 0.2s; font-size: 10px; gap: 2px;
    border: none; background: none;
}
.nav-item .nav-icon { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: scale(1.1); }

/* ====== PAGES ====== */
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* ====== CARDS ====== */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ====== SUMMARY CARDS ====== */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.summary-card {
    background: white; border-radius: var(--radius); padding: 14px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.summary-card.green  { border-left: 4px solid var(--primary); }
.summary-card.blue   { border-left: 4px solid var(--accent); }
.summary-card.orange { border-left: 4px solid var(--warning); }
.summary-card.red    { border-left: 4px solid var(--danger); }
.summary-card .s-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.summary-card .s-value { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.2; }
.summary-card .s-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 28px; opacity: 0.12; }

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer;
    border: none; transition: all 0.15s; text-decoration: none;
    white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover   { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger    { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 6px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ====== FORMS ====== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 5px; }
.form-control {
    width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; color: var(--text);
    background: white; transition: border-color 0.15s;
    -webkit-appearance: none; appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control.error { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ====== TABS ====== */
.tab-bar { display: flex; background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.tab-btn { flex: 1; padding: 10px 8px; text-align: center; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text-muted); border: none; background: none; transition: all 0.2s; }
.tab-btn.active { background: var(--primary); color: white; }

/* ====== TRANSACTION LIST ====== */
.tx-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid #f3f4f6;
    cursor: pointer; transition: background 0.1s;
}
.tx-item:last-child { border-bottom: none; }
.tx-item:active { background: #f9fafb; }
.tx-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.tx-icon.income  { background: var(--primary-light); }
.tx-icon.expense { background: #fee2e2; }
.tx-icon.rukem   { background: #fef9c3; }
.tx-body { flex: 1; min-width: 0; }
.tx-cat  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.tx-meta .source-badge { background: #f1f5f9; border-radius: 4px; padding: 1px 6px; }
.tx-amount { font-size: 14px; font-weight: 600; flex-shrink: 0; }
.tx-amount.income  { color: var(--primary); }
.tx-amount.expense { color: var(--danger); }
.tx-amount.rukem   { color: var(--warning); }

/* ====== LAPORAN TABEL ====== */
.report-section { margin-bottom: 16px; }
.report-section-title { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; font-size: 12px; padding: 8px 12px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; letter-spacing: 0.5px; text-transform: uppercase; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid #f3f4f6; }
.report-table .col-label { color: var(--text); }
.report-table .col-amount { text-align: right; font-weight: 500; white-space: nowrap; }
.report-table .indent { padding-left: 24px; color: var(--text-muted); }
.report-table .total-row td { font-weight: 700; background: var(--primary-light); color: var(--primary-dark); }
.report-table .grand-total td { font-weight: 700; background: var(--primary); color: white; font-size: 14px; }

/* ====== MODAL ====== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 200; display: none; align-items: flex-end;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: white; border-radius: var(--radius) var(--radius) 0 0;
    width: 100%; max-width: 500px; max-height: 92vh;
    overflow-y: auto; padding: 20px;
    animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: #f3f4f6; border: none; border-radius: 50%; width: 32px; height: 32px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }

/* ====== BADGE ====== */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.badge-income  { background: var(--primary-light); color: var(--primary-dark); }
.badge-expense { background: #fee2e2; color: #991b1b; }
.badge-rukem   { background: #fef9c3; color: #92400e; }
.badge-bank    { background: #dbeafe; color: #1e40af; }
.badge-cash    { background: #f3f4f6; color: #374151; }

/* ====== EMPTY STATE ====== */
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 8px; opacity: 0.5; }
.empty-state p { font-size: 13px; }

/* ====== LOADING ====== */
.loading { text-align: center; padding: 24px; color: var(--text-muted); }
.spinner { display: inline-block; width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== ALERT ====== */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.alert-success { background: var(--primary-light); color: var(--primary-dark); border-left: 3px solid var(--primary); }
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--danger); }
.alert-info    { background: #dbeafe; color: #1e40af; border-left: 3px solid var(--accent); }

/* ====== LOGIN ====== */
#login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary), #4ade80);
    padding: 20px;
}
.login-card {
    background: white; border-radius: 16px; padding: 32px 24px;
    width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .icon { font-size: 48px; margin-bottom: 8px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--primary-dark); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ====== FAB ====== */
.fab {
    position: fixed; bottom: 72px; right: 20px;
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--primary); color: white;
    box-shadow: 0 4px 16px rgba(21,128,61,0.4);
    border: none; cursor: pointer; font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    z-index: 90; transition: transform 0.15s;
}
.fab:active { transform: scale(0.95); }

/* ====== PERIOD SELECTOR ====== */
.period-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.period-bar select { flex: 1; }
.period-bar .export-btns { display: flex; gap: 6px; }

/* ====== TOAST ====== */
.toast {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.85); color: white;
    padding: 10px 18px; border-radius: 20px; font-size: 13px;
    z-index: 300; opacity: 0; transition: opacity 0.2s;
    pointer-events: none; white-space: nowrap;
    max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--primary); }
.toast.error   { background: var(--danger); }

/* ====== RESPONSIVE ====== */
@media (max-width: 360px) {
    .summary-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .s-value { font-size: 14px; }
}
@media (min-width: 600px) {
    #page-content { max-width: 600px; margin: 0 auto; }
    #bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); }
    .fab { right: calc(50% - 280px); }
    .modal { border-radius: var(--radius); }
    .modal-overlay { align-items: center; }
}

/* ====== SETUP PAGE ====== */
.setup-container {
    min-height: 100vh; display: flex; align-items: flex-start; justify-content: center;
    background: var(--bg); padding: 20px;
}
.setup-card { background: white; border-radius: 16px; padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow-md); }
.setup-header { text-align: center; margin-bottom: 24px; }
.setup-header .icon { font-size: 40px; margin-bottom: 8px; }
.setup-header h2 { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.setup-header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ====== PRINT STYLES ====== */
@media print {
    #topbar, #bottom-nav, .fab, .period-bar .export-btns { display: none !important; }
    .page { display: block !important; padding: 0; }
    .card { box-shadow: none; border: 1px solid var(--border); }
}
.tx-icon.transfer { background: #dbeafe; }
.tx-amount.transfer { color: #1d4ed8; }
