@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(23, 32, 53, 0.55);
    --card-bg-solid: #172035;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-hover: rgba(255, 255, 255, 0.15);
    
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.25);
    
    --secondary: #0ea5e9;
    --secondary-hover: #0284c7;
    --secondary-glow: rgba(14, 165, 233, 0.25);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    
    --danger: #f43f5e;
    --danger-glow: rgba(244, 63, 94, 0.2);
    
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.2);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.08) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(14, 165, 233, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 10px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.brand-logo svg {
    color: white;
    width: 22px;
    height: 22px;
}

.brand-name {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item a:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active a {
    color: white;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(14, 165, 233, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.05);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    transition: var(--transition);
}

.nav-item.active svg {
    color: var(--primary);
    filter: drop-shadow(0 0 5px var(--primary));
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    padding: 40px;
    overflow-y: auto;
    height: 100vh;
}

/* Top Section Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.page-title h2 {
    font-size: 1.85rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.page-title p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Custom Period Container */
.period-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.9rem;
}

/* Glassmorphism Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255,255,255,0.05);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-color-hover);
    transform: translateY(-2px);
}

/* Stats Widgets Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.income::before { background: var(--success); }
.stat-card.expense::before { background: var(--danger); }
.stat-card.remaining::before { background: var(--primary); }

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.stat-card.income .stat-icon { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.stat-card.expense .stat-icon { background: rgba(244, 63, 94, 0.12); color: var(--danger); }
.stat-card.remaining .stat-icon { background: rgba(139, 92, 246, 0.12); color: var(--primary); }

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.stat-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Dashboard Sections */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
    margin-bottom: 30px;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.section-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color-hover);
}

.btn-danger {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 15px var(--danger-glow);
}

.btn-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.btn-success:hover {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 15px var(--success-glow);
}

.btn-icon-only {
    padding: 10px;
    border-radius: 10px;
}

/* Budget Progress Bars */
.budget-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.budget-item {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 14px;
    padding: 16px;
    transition: var(--transition);
}

.budget-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
}

.budget-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.budget-name-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.budget-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.budget-values {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.budget-values span {
    color: var(--text-color);
    font-weight: 700;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    width: 0;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.budget-warning-text {
    font-size: 0.75rem;
    text-align: right;
    font-weight: 500;
}

/* Transactions Table View */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.tx-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.tx-table th {
    padding: 12px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 0.5px;
}

.tx-table td {
    padding: 16px;
    font-size: 0.92rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.tx-table tr:last-child td {
    border-bottom: none;
}

.tx-table tr {
    transition: var(--transition);
}

.tx-table tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

/* Badge Layouts */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-income { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.badge-expense { background: rgba(244, 63, 94, 0.12); color: #f87171; }
.badge-fixed { background: rgba(139, 92, 246, 0.12); color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(255, 255, 255, 0.06);
}

select.form-control option {
    background-color: var(--card-bg-solid);
    color: var(--text-color);
}

/* Category Dropdown Styling in Table */
.category-select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 10px;
    font-size: 0.82rem;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    max-width: 160px;
    transition: var(--transition);
}

.category-select:focus, .category-select:hover {
    border-color: var(--secondary);
    background: rgba(255, 255, 255, 0.06);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--card-bg-solid);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.modal-backdrop.show .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1100;
}

.toast {
    background: var(--card-bg-solid);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 12px;
    padding: 14px 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
    transform: translateX(0);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }

/* Bank accounts & Simulator panel */
.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.account-card {
    background: linear-gradient(135deg, rgba(23, 32, 53, 0.6), rgba(30, 41, 59, 0.4));
    border-left: 4px solid var(--secondary);
}

.account-card.n26 {
    border-left-color: var(--primary);
}

.account-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.account-iban {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

.account-balance {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-color);
}

/* Simulator Widget styling */
.simulator-box {
    background: rgba(139, 92, 246, 0.05);
    border: 1px dashed rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.simulator-info h4 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--primary);
    font-weight: 700;
}

.simulator-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Empty State styling */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: rgba(255,255,255,0.1);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* Chart Canvas container */
.chart-container {
    position: relative;
    height: 220px;
    width: 100%;
}

/* Grid Layouts for Management Pages */
.manage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 850px) {
    .manage-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive sidebar adaptations */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        height: auto;
        position: relative;
        padding: 20px;
    }
    
    .brand {
        margin-bottom: 20px;
    }
    
    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 10px;
        gap: 12px;
    }
    
    .nav-item a {
        padding: 10px 14px;
        white-space: nowrap;
    }
    
    .main-content {
        padding: 20px;
        height: auto;
    }
    
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        margin-bottom: 24px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
}
