/* File: assets/css/app.css
   Modern, Responsive, Professional Design System
*/

.finance-manager td strong, .finance-manager td .text-muted { overflow-wrap: anywhere; }
@media (max-width: 767px) {
    .finance-manager td[data-label="Tên"], .ledger-table td[data-label="Nội dung"] {
        display: block;
        text-align: left;
    }
    .finance-manager td[data-label="Tên"]::before, .ledger-table td[data-label="Nội dung"]::before {
        display: block;
        margin-bottom: 6px;
    }
}

:root {
    /* Color Palette - Light Mode */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --dark: #0f172a;
    
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border: rgba(0, 0, 0, 0.08);
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-primary: #ffffff;
    
    --card-radius: 20px;
    --btn-radius: 12px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --header-height: 64px;
}

/* Dark Mode Variables */
html.dark-mode, body.dark-mode {
    background-color: #020617 !important;
}

body.dark-mode {
    --bg-main: #020617;
    --bg-surface: #0f172a;
    --bg-glass: rgba(15, 23, 42, 0.8);
    --border: rgba(255, 255, 255, 0.08);
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* Background Gradients */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent),
                radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent);
    z-index: -1;
    pointer-events: none;
    transition: background 0.3s ease;
}

body.dark-mode::before {
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent),
                radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.02), transparent);
}

.dashboard {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    margin-top: 20px;
}

/* Typography Overrides */
h1, h2, h3, h4, .fw-bold {
    color: var(--text-main);
    letter-spacing: -0.025em;
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.card-summary {
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.card-summary h6 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
    margin-bottom: 8px;
}

.card-summary h3, .card-summary h4 {
    font-weight: 800;
    margin: 0;
}

/* Gradients for Cards */
.bg-gradient-success { background: linear-gradient(135deg, #10b981, #059669); color: white; }
.bg-gradient-danger  { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.bg-gradient-primary { background: linear-gradient(135deg, #6366f1, #4f46e5); color: white; }
.bg-gradient-dark    { background: linear-gradient(135deg, #1e293b, #0f172a); color: white; }
.bg-gradient-warning { background: linear-gradient(135deg, #f59e0b, #d97706); color: #000; }
.bg-gradient-info    { background: linear-gradient(135deg, #0ea5e9, #0284c7); color: white; }

body.dark-mode .bg-gradient-success { background: linear-gradient(135deg, #065f46, #064e3b); }
body.dark-mode .bg-gradient-danger  { background: linear-gradient(135deg, #991b1b, #7f1d1d); }
body.dark-mode .bg-gradient-primary { background: linear-gradient(135deg, #3730a3, #312e81); }
body.dark-mode .bg-gradient-warning { background: linear-gradient(135deg, #92400e, #78350f); color: white; }
body.dark-mode .bg-gradient-info    { background: linear-gradient(135deg, #075985, #0c4a6e); }

/* Table Overrides */
.table-responsive {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}

.table {
    margin-bottom: 0;
    color: var(--text-main);
}

.table thead th {
    background: #f1f5f9;
    border-bottom: 2px solid var(--border);
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

body.dark-mode .table thead th {
    background: #1e293b;
}

.table td {
    padding: 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

/* Tabs Styling */
.nav-tabs {
    border-bottom: none;
    gap: 8px;
    padding: 4px;
    background: var(--bg-surface);
    border-radius: 16px;
    display: inline-flex;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.nav-tabs .nav-link {
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    color: var(--text-muted);
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Topbar */
.app-topbar {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Buttons */
.btn {
    border-radius: var(--btn-radius);
    font-weight: 600;
    padding: 10px 20px;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary { background-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-1px); }

/* Dark Mode Toggle */
.toggle-dark {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-surface);
    border-radius: 20px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .dashboard {
        padding: 16px;
        border-radius: 0;
        margin-top: 0;
    }
    
    .card-summary {
        padding: 16px;
    }
    
    .nav-tabs {
        display: flex;
        width: 100%;
    }
    
    .nav-tabs .nav-item {
        flex: 1;
    }
    
    .nav-tabs .nav-link {
        text-align: center;
        padding: 8px;
        font-size: 0.8rem;
    }
    
    /* Responsive Tables */
    .table thead {
        display: none;
    }
    
    .table tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--bg-surface);
    }
    
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 8px 16px;
        border-bottom: 1px solid var(--border);
    }
    
    .table td:last-child {
        border-bottom: none;
    }
    
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
    }
    
    .table td:empty::before {
        content: "";
    }
    
    .table td.actions {
        justify-content: center;
        gap: 8px;
    }
}

/* Floating Action Button for Mobile */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    font-size: 24px;
    border: none;
}

@media (max-width: 768px) {
    .fab { display: flex; }
}

/* Premium Mobile Navbar Refinement */
@media (max-width: 991px) {
    .navbar-collapse.bg-glass-mobile {
        background: var(--bg-surface) !important;
        border-radius: 20px;
        margin-top: 12px;
        padding: 20px;
        box-shadow: var(--shadow-lg);
        border: 1px solid var(--border);
    }
    .navbar-nav .btn { margin-bottom: 8px; }
}

.navbar-toggler:focus { box-shadow: none; }

/* Banking Typography & Utilities */
.fw-extrabold { font-weight: 800; }
.bg-soft-primary { background-color: rgba(99, 102, 241, 0.1); }

/* Custom Sleek Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Theme-aware Glass Cards */
.bg-glass-card {
    background: var(--bg-surface);
    border: 1px solid var(--border) !important;
}

body.dark-mode .card-header, 
body.dark-mode .card-footer {
    background-color: rgba(255, 255, 255, 0.03) !important;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

body.dark-mode .bg-white {
    background-color: var(--bg-surface) !important;
}
