/* ==========================================================================
   CSS Variables & Typography
   ========================================================================== */
   :root {
    --primary-hue: 220;
    --primary: hsl(var(--primary-hue), 85%, 55%);
    --primary-dark: hsl(var(--primary-hue), 85%, 45%);
    --primary-light: hsl(var(--primary-hue), 85%, 95%);
    
    --success: hsl(142, 70%, 45%);
    --success-light: hsl(142, 70%, 95%);
    
    --danger: hsl(348, 80%, 50%);
    --danger-light: hsl(348, 80%, 95%);
    
    --bg-color: hsl(220, 20%, 97%);
    --surface: hsl(0, 0%, 100%);
    --surface-glass: rgba(255, 255, 255, 0.85);
    
    --text-main: hsl(220, 30%, 15%);
    --text-muted: hsl(220, 15%, 50%);
    
    --border: hsl(220, 20%, 90%);
    --border-glass: rgba(255, 255, 255, 0.2);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.05);
    --shadow-glass: 0 8px 32px rgba(31, 38, 135, 0.05);
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.05), transparent 25%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   Utilities & Glassmorphism
   ========================================================================== */
.glass-panel {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.m-0 { margin: 0; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

h1, h2, h3, h4 { color: var(--text-main); font-weight: 600; line-height: 1.2; }

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.25);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.3);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
}
.btn-outline:hover { background-color: var(--bg-color); border-color: var(--primary); color: var(--primary); }

.btn-icon, .btn-icon-small {
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center; justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover { background-color: var(--bg-color); color: var(--primary); }
.btn-icon-small { padding: 0.25rem; font-size: 1.1rem; }

.btn-danger-text:hover { color: var(--danger); background-color: var(--danger-light); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* Inputs */
input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--surface);
    transition: var(--transition);
    outline: none;
}
input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
input:disabled, select:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    color: var(--text-muted);
}

.input-with-prefix {
    display: flex;
    align-items: center;
}
.input-with-prefix span {
    background-color: var(--bg-color);
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
}
.input-with-prefix input {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ==========================================================================
   View Switching Logic
   ========================================================================== */
.view-container {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    transition: opacity 0.4s ease, visibility 0.4s;
    display: flex;
    flex-direction: column;
}
.view-container.active {
    opacity: 1;
    visibility: visible;
    position: relative;
    min-height: 100vh;
}

/* ==========================================================================
   Login View
   ========================================================================== */
#login-view {
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem 2rem;
    text-align: center;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 2rem;
    border-radius: var(--radius-lg);
    display: flex; justify-content: center; align-items: center;
    margin: 0 auto 1.5rem auto;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}
.login-box h2 { margin-bottom: 0.5rem; }
.login-box p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; }

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}
.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}
.input-group input {
    padding-left: 2.75rem;
}
#login-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 1rem;
    background: var(--danger-light);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Dashboard Navigation
   ========================================================================== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}
.nav-brand i { color: var(--primary); font-size: 1.5rem; }
.nav-brand small { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; letter-spacing: 0.5px; text-transform: uppercase; }
.nav-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ==========================================================================
   Dashboard Main Content
   ========================================================================== */
.dashboard-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.5s ease;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.card {
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,0,0,0.06); }
.card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    position: relative;
    z-index: 2;
    cursor: pointer;
}
.card-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex; justify-content: center; align-items: center;
    font-size: 1.5rem;
}
.card-balance .card-icon { background: var(--primary-light); color: var(--primary); }
.card-income .card-icon { background: var(--success-light); color: var(--success); }
.card-expense .card-icon { background: var(--danger-light); color: var(--danger); }

.card-info h3 { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.25rem; text-transform: uppercase; letter-spacing: 0.5px; }
.card-info h2 { font-size: 1.75rem; margin: 0; letter-spacing: -0.5px; }

/* Card Expandable (Subtotals) */
.is-expandable { padding: 0; }
.is-expandable .card-header { padding: 1.5rem; }
.expand-icon { margin-left: auto; color: var(--text-muted); transition: transform 0.3s; font-size: 1.25rem; align-self: center; }
.card.expanded .expand-icon { transform: rotate(180deg); }

.card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background: #f8fafc;
    border-top: 1px solid var(--border);
}
.card.expanded .card-details { max-height: 300px; }

.subtotal-list {
    list-style: none;
    padding: 0.5rem 1.5rem 1.5rem 1.5rem;
    margin: 0;
}
.subtotal-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.9rem;
}
.subtotal-item:last-child { border-bottom: none; padding-bottom: 0; }
.subtotal-label { color: var(--text-muted); }
.subtotal-value { font-weight: 600; }
.subtotal-value.pos { color: var(--success); }
.subtotal-value.neg { color: var(--danger); }


/* Action Bar (Filters) */
.action-bar {
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.filter-group {
    position: relative;
    display: flex;
    align-items: center;
}
.filter-group i {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}
.filter-group select {
    padding-left: 2.25rem;
    padding-block: 0.5rem;
    min-width: 150px;
    height: 40px;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}
th, td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}
tbody tr { background: transparent; transition: var(--transition); }
tbody tr:hover { background: rgba(255, 255, 255, 0.5); }
tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.Pemasukan { background: var(--success-light); color: var(--success); }
.badge.Pengeluaran { background: var(--danger-light); color: var(--danger); }

.amount { font-weight: 600; font-family: 'Inter', monospace; }
.amount.pos { color: var(--success); }
.amount.neg { color: var(--danger); }

/* Table Actions */
td .btn-icon-small { opacity: 0.4; margin: 0 0.1rem; }
tr:hover td .btn-icon-small { opacity: 1; }

.proof-indicator {
    cursor: pointer;
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    display: inline-flex;
    align-items: center; gap: 0.25rem;
    font-size: 0.85rem; font-weight: 500;
    transition: var(--transition);
}
.proof-indicator:hover { background: var(--primary); color: white; }
.proof-indicator.empty { background: transparent; color: var(--text-muted); border: 1px dashed var(--border); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex; justify-content: center; align-items: center;
    padding: 1rem;
    opacity: 0; visibility: hidden; transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    transform: scale(0.95) translateY(20px);
    transition: var(--transition);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-overlay.active .modal-content { transform: scale(1) translateY(0); }

.modal-content.modal-lg { max-width: 800px; }

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.15rem; margin: 0; }
.btn-close-modal { background: transparent; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; }
.btn-close-modal:hover { color: var(--danger); }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Forms inside modal */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
.form-row { display: flex; gap: 1rem; }
.form-row .half { flex: 1; }

/* File Upload Zone */
.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--primary);
    border-radius: var(--radius-md);
    background: var(--primary-light);
    color: var(--primary-dark);
    cursor: pointer;
    transition: var(--transition);
    gap: 0.5rem;
}
.upload-label:hover { background: #dbeafe; }
.upload-label i { font-size: 2.5rem; }

.file-list { list-style: none; padding: 0; margin: 0; }
.file-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.file-item i.ri-file-text-line { color: var(--text-muted); margin-right: 0.75rem; font-size: 1.2rem; }
.file-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-actions { display: flex; gap: 0.25rem; }

/* Small Tables inside Modals */
.small-table table th, .small-table table td { padding: 0.75rem 1rem; font-size: 0.85rem; }
.small-table input[type="number"] { width: 70px; padding: 0.3rem; height: auto; text-align: center; }

/* ==========================================================================
   Public View (Share Link) Overrides
   ========================================================================== */
.public-nav {
    justify-content: center; position: relative;
}
.public-nav .nav-actions { position: absolute; right: 2rem; }
.public-nav .badge { background: #fef08a; color: #854d0e; }
.public-action-bar { border-radius: var(--radius-lg); margin-bottom: -0.5rem; }

/* ==========================================================================
   Toast / Spinner / Animations
   ========================================================================== */
#toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    background: var(--surface); color: var(--text-main); fill: var(--text-main);
    padding: 1rem 1.25rem; border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); border-left: 4px solid var(--primary);
    display: flex; align-items: center; gap: 0.75rem; font-weight: 500; font-size: 0.9rem;
    animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-info { border-color: var(--primary); }
.toast i { font-size: 1.25rem; }
.toast-success i { color: var(--success); }
.toast-error i { color: var(--danger); }

@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.spinner {
    display: inline-block;
    width: 1.5rem; height: 1.5rem;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    -webkit-animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { -webkit-transform: rotate(360deg); } }

/* ==========================================================================
   Breakpoints (Responsive)
   ========================================================================== */
@media (max-width: 768px) {
    .dashboard-content { padding: 1rem; }
    .action-bar { flex-direction: column; align-items: stretch; }
    .filters { flex-direction: column; width: 100%; }
    .filter-group { width: 100%; }
    .filter-group select { width: 100%; }
    .form-row { flex-direction: column; gap: 0; }
    .public-nav .nav-actions { position: static; margin-top: 0.5rem; display: block; text-align: center; }
    .public-nav { flex-direction: column; }
}
