/* ==========================================================================
   SIKEU BUMDes — UI Components (Cards, KPIs, Tables, Forms, Modals, Charts)
   ========================================================================== */

/* Cards & Grids */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.card-body {
    padding: 18px;
}

.grid {
    display: grid;
    gap: 16px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--primary);
}
.kpi-card.blue { border-top-color: #0284c7; }
.kpi-card.amber { border-top-color: #d97706; }
.kpi-card.slate { border-top-color: #475569; }
.kpi-card.red { border-top-color: #dc2626; }

.kpi-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kpi-value {
    font-size: 21px;
    font-weight: 800;
    color: var(--text);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: var(--primary-light); border-color: var(--primary-border); color: var(--primary-dark); }
.alert-error   { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-bg); border-color: #fde68a; color: #92400e; }
.alert-info    { background: var(--info-bg); border-color: #bae6fd; color: #075985; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.3;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-subtle); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-lg { padding: 6px 12px; font-size: 12.5px; }
.badge-emerald { background: #d1fae5; color: var(--primary-dark); }
.badge-blue    { background: #e0f2fe; color: #075985; }
.badge-amber   { background: #fef3c7; color: #92400e; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-purple  { background: #f3e8ff; color: #6b21a8; }
.badge-slate   { background: #e2e8f0; color: #334155; }
.badge-muted   { background: #f1f5f9; color: var(--text-muted); text-decoration: line-through; }

/* Tables */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}
table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table th, .table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.table th {
    background: var(--surface-subtle);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
}
.table tbody tr:hover { background: #f8fafc; }
.table tr.row-subtotal td {
    background: #f8fafc;
    font-weight: 700;
    border-top: 1px solid var(--border-strong);
}
.table tr.row-total td {
    background: var(--primary-light);
    color: var(--primary-darker);
    font-weight: 800;
    border-top: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
}
.table tr.row-section td {
    background: #f1f5f9;
    font-weight: 700;
    color: #334155;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Forms & Filters */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
}
.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-control, select.form-control, textarea.form-control {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 150px; }

/* Transaction Mode Selector Cards */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.mode-card {
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-family: inherit;
}
.mode-card:hover { border-color: #94a3b8; }
.mode-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}
.mode-card-title { font-weight: 700; font-size: 13.5px; color: var(--text); }
.mode-card-title--income { color: #047857; }
.mode-card-title--expense { color: #b45309; }
.mode-card-title--modal { color: #0369a1; }
.mode-card-title--asset { color: #475569; }
.mode-card-title--transfer { color: #0f172a; }
.mode-card-title--interunit { color: #6b21a8; }
.mode-card-title--shu { color: #065f46; }
.mode-card-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* Simple Bar Chart */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding-top: 16px;
    border-bottom: 1px solid var(--border);
}
.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.chart-pair {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 145px;
    width: 100%;
    justify-content: center;
}
.bar-rev, .bar-exp {
    width: 42%;
    max-width: 16px;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height 0.3s;
}
.bar-rev { background: #10b981; }
.bar-exp { background: #f59e0b; }
.chart-lbl { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    vertical-align: middle;
}
.legend-dot--rev { background: #10b981; }
.legend-dot--exp { background: #f59e0b; }

/* Modals */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-body { padding: 18px; }

/* SweetAlert2 Theme Overrides */
.swal2-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    border-radius: 16px !important;
    padding: 1.6em 1.4em 1.4em !important;
}
.swal2-title { font-size: 1.3em !important; color: #0f172a !important; font-weight: 700 !important; }
.swal2-html-container { font-size: 0.95em !important; color: #475569 !important; line-height: 1.55 !important; }
.swal2-actions { gap: 8px; }
.swal2-styled { border-radius: 9px !important; font-weight: 600 !important; padding: 0.6em 1.3em !important; font-size: 0.92em !important; }
.swal2-styled:focus { box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.25) !important; }
.swal2-toast { border-radius: 12px !important; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15) !important; }
.swal2-toast .swal2-title { font-size: 0.92em !important; font-weight: 600 !important; }
.swal2-timer-progress-bar { background: rgba(4, 120, 87, 0.45) !important; }

@media (max-width: 960px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
