/* ==========================================================================
   PERSONAL FINANCE & BILLING MANAGEMENT SYSTEM - DESIGN SYSTEM
   Theme: Modern SaaS (Notion / Stripe / Linear / Vercel Quality)
   ========================================================================== */

:root {
    --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Brand Color Palette */
    --primary-color: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-subtle: rgba(37, 99, 235, 0.12);
    
    --secondary-color: #6366F1;
    --secondary-hover: #4F46E5;
    --secondary-subtle: rgba(99, 102, 241, 0.12);
    
    --success-color: #16A34A;
    --success-subtle: rgba(22, 163, 74, 0.12);
    
    --warning-color: #F59E0B;
    --warning-subtle: rgba(245, 158, 11, 0.12);
    
    --danger-color: #DC2626;
    --danger-subtle: rgba(220, 38, 38, 0.12);
    
    --dark-bg: #0F172A;
    --dark-card: #1E293B;
    --dark-border: #334155;
    
    /* Layout Constants */
    --sidebar-width: 280px;
    --topbar-height: 70px;
    
    /* Radius Tokens */
    --border-radius-lg: 18px;
    --border-radius-md: 14px;
    --border-radius-sm: 10px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.12);
    --shadow-glow: 0 8px 25px rgba(37, 99, 235, 0.25);
    
    /* Transitions */
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    color: #1E293B;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

@media (max-width: 991.98px) {
    .main-content-wrapper {
        margin-left: 0;
    }
}

/* ==========================================================================
   SIDEBAR STYLING
   ========================================================================== */

.app-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.25rem;
    background-color: var(--bs-body-bg);
    border-right: 1px solid var(--bs-border-color);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    
    .app-sidebar.show {
        transform: translateX(0);
    }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.brand-icon-wrapper {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

.sidebar-nav .nav-link {
    color: var(--bs-body-color);
    font-weight: 500;
    font-size: 0.925rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-md);
    transition: var(--transition-fast);
}

.sidebar-nav .nav-link:hover {
    background-color: var(--bs-tertiary-bg);
    color: var(--primary-color);
    transform: translateX(4px);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--primary-color), #3B82F6);
    color: #ffffff !important;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.sidebar-nav .nav-link.active .nav-icon {
    color: #ffffff !important;
}

.sidebar-nav .nav-icon {
    font-size: 1.15rem;
    color: #64748B;
    transition: var(--transition-fast);
}

.sidebar-pro-card {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(99, 102, 241, 0.08));
    border: 1px solid rgba(37, 99, 235, 0.15) !important;
}

/* ==========================================================================
   TOPBAR STYLING
   ========================================================================== */

.app-topbar {
    height: var(--topbar-height);
    background: rgba(var(--bs-body-bg-rgb), 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--bs-border-color);
    z-index: 1020;
}

.topbar-search input {
    width: 280px;
    transition: width 0.3s ease, box-shadow 0.3s ease;
}

.topbar-search input:focus {
    width: 340px;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    background-color: var(--bs-body-bg) !important;
}

.topbar-search .search-icon {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
}

.btn-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    transform: translateY(-2px);
}

.avatar-wrapper img {
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.status-indicator {
    width: 10px;
    height: 10px;
}

/* ==========================================================================
   CARDS & GLASSMORPHISM
   ========================================================================== */

.card-custom {
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

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

.card-glass {
    background: rgba(var(--bs-body-bg-rgb), 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-bs-theme="dark"] .card-glass {
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.welcome-card {
    background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 50%, #4F46E5 100%);
    border-radius: var(--border-radius-lg);
    position: relative;
    overflow: hidden;
    color: #ffffff;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.3);
}

.welcome-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.stat-card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* ==========================================================================
   BUTTONS & BADGES
   ========================================================================== */

.btn {
    border-radius: 12px;
    padding: 0.6rem 1.25rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border: none;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #1E40AF);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #15803D);
    border: none;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.25);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #B91C1C);
    border: none;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}

.badge-status {
    padding: 0.4em 0.85em;
    font-weight: 600;
    border-radius: 50rem;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.badge-status-paid {
    background-color: var(--success-subtle);
    color: var(--success-color);
}

.badge-status-pending {
    background-color: var(--warning-subtle);
    color: #D97706;
}

.badge-status-partial {
    background-color: var(--primary-subtle);
    color: var(--primary-color);
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */

.form-control, .form-select {
    border-radius: 12px;
    padding: 0.65rem 1rem;
    border: 1px solid var(--bs-border-color);
    font-size: 0.925rem;
    transition: var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.floating-label-custom .form-control {
    border-radius: 12px;
}

/* ==========================================================================
   TABLES
   ========================================================================== */

.table-custom {
    border-collapse: separate;
    border-spacing: 0 8px;
}

.table-custom tbody tr {
    background-color: var(--bs-body-bg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    transition: var(--transition-fast);
}

.table-custom tbody tr:hover {
    transform: scale(1.002);
    box-shadow: var(--shadow-sm);
    background-color: var(--bs-tertiary-bg);
}

.table-custom td, .table-custom th {
    padding: 1rem 1.25rem;
    vertical-align: middle;
}

.table-custom th {
    border: none;
    font-size: 0.75rem;
    text-uppercase: uppercase;
    letter-spacing: 0.5px;
    color: #64748B;
    font-weight: 600;
}

.table-custom td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.table-custom td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* ==========================================================================
   DARK MODE OVERRIDES
   ========================================================================== */

[data-bs-theme="dark"] {
    --bs-body-bg: var(--dark-bg);
    --bs-body-bg-rgb: 15, 23, 42;
    --bs-body-color: #F8FAFC;
    --bs-tertiary-bg: #1E293B;
    --bs-border-color: var(--dark-border);
}

[data-bs-theme="dark"] .card-custom,
[data-bs-theme="dark"] .app-sidebar {
    background-color: var(--dark-card);
    border-color: var(--dark-border);
}

[data-bs-theme="dark"] .table-custom tbody tr {
    background-color: var(--dark-card);
}

[data-bs-theme="dark"] .table-custom tbody tr:hover {
    background-color: #283548;
}

[data-bs-theme="dark"] .topbar-search input {
    background-color: #1E293B !important;
    color: #F8FAFC;
}

/* ==========================================================================
   INVOICE PRINT STYLE RULES
   ========================================================================== */

@media print {
    .app-sidebar,
    .app-topbar,
    .btn-print-hide,
    .sidebar-overlay {
        display: none !important;
    }

    .main-content-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .invoice-card {
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        color: black !important;
    }
}

/* ==========================================================================
   UTILITY CLASSES & ANIMATIONS
   ========================================================================== */

.fs-7 { font-size: 0.85rem; }
.fs-8 { font-size: 0.775rem; }
.fs-9 { font-size: 0.7rem; }

.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.fade-in {
    animation: fadeIn 0.4s ease-in-out;
}

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