/* ===========================================================
   Keuangan App — shared design system
   Loaded on every page after Bootstrap + Font Awesome.
   =========================================================== */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --sidebar-bg: #1e1b3a;
    --sidebar-bg-active: #4f46e5;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 76px;
    --surface: #ffffff;
    --bg: #f4f5fb;
    --border: #e5e7eb;
    --text: #1f2330;
    --text-muted: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(31, 35, 48, 0.06);
    --shadow-lg: 0 10px 40px rgba(31, 35, 48, 0.10);
}

* {
    box-sizing: border-box;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body {
    margin: 0;
}

a {
    color: var(--primary);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text);
}

/* ---------- App shell / content offset ---------- */

#content,
.app-content {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    transition: margin-left .3s ease, width .3s ease, max-width .3s ease;
}

body.sidebar-collapsed #content,
body.sidebar-collapsed .app-content {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
    max-width: calc(100% - var(--sidebar-width-collapsed));
}

@media (max-width: 992px) {
    #content,
    .app-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 18px;
    }
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-header .page-title {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header .page-title i {
    color: var(--primary);
}

.page-header .page-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Cards ---------- */

.app-card,
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.app-card .app-card-header,
.card-header-custom {
    background: var(--gradient);
    color: #fff;
    padding: 20px 24px;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
}

.app-card .app-card-header h2,
.app-card .app-card-header h3 {
    color: #fff;
    margin: 0;
}

.app-card-body {
    padding: 22px 24px;
}

/* ---------- Buttons ---------- */

.btn-primary,
.btn-custom-primary {
    background: var(--gradient);
    border: none;
}

.btn-primary:hover,
.btn-custom-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
}

/* ---------- Tables ---------- */

.table-wrapper {
    overflow-x: auto;
    width: 100%;
    border-radius: var(--radius-sm);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fc;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11.5px;
    letter-spacing: .03em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    padding: 12px 16px;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 13.5px;
}

.table tbody tr:hover {
    background-color: #f8f9fc;
}

/* ---------- Badges ---------- */

.badge {
    font-weight: 600;
    letter-spacing: .01em;
}

/* ---------- Profit / loss helpers ---------- */

.profit-positive {
    color: var(--success) !important;
    font-weight: 700;
    background-color: rgba(16, 185, 129, .1);
    border-radius: 6px;
}

.profit-negative {
    color: var(--danger) !important;
    font-weight: 700;
    background-color: rgba(239, 68, 68, .1);
    border-radius: 6px;
}

/* ---------- Forms ---------- */

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 8px 12px;
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .18);
}

/* ---------- Modals ---------- */

.modal-content {
    border-radius: var(--radius);
    border: none;
    overflow: hidden;
}

.modal-header {
    background: var(--gradient);
    color: #fff;
}

.modal-header .btn-close {
    background-color: #fff;
    border-radius: 50%;
    opacity: .85;
}

/* ---------- Empty state ---------- */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 56px;
    color: var(--border);
    margin-bottom: 16px;
}

/* ---------- Scrollbars ---------- */

.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #c7c9d9;
    border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a3a6c2;
}

/* ---------- Fade-in ---------- */

@keyframes appFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-card {
    animation: appFadeIn .4s ease-out;
}
