/* ==================== ROOT VARIABLES ==================== */
:root {
    --primary-purple: #6366f1;
    --primary-pink: #ec4899;
    --success-green: #10b981;
    --warning-orange: #f59e0b;
    --danger-red: #ef4444;
    --dark-purple: #1e1b4b;
    --medium-purple: #312e81;
    --light-purple: #4c1d95;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-white: #ffffff;
    --text-gray: rgba(255, 255, 255, 0.7);
}

/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(93deg, #1e1b4b 0%, #202ca5 50%, #261760 100%);
    min-height: 100vh;
    color: var(--text-white);
    overflow-x: hidden;
}

.budget-app {
    width: 100%;
    min-height: 100vh;
    padding: 0;
}

/* ==================== HEADER ==================== */
.budget-header {
    background: rgba(17, 24, 39, 0.3);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-logo {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-white);
}

.header-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* ==================== DROPDOWN MENUS ==================== */
.dropdown {
    position: relative;
}

.dropdown-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px 16px;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.dropdown-button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    min-width: 200px;
    display: none;
    z-index: 1001;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dropdown.active .dropdown-menu {
    display: block;
    animation: slideDown 0.3s ease;
}

.dropdown-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    color: white;
}

.dropdown-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-menu-item.selected {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-purple);
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-pink));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: var(--success-green);
    color: white;
}

/* ==================== LAYOUT ==================== */
.budget-app-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ==================== SIDEBAR ==================== */
.budget-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ==================== GLASS CARDS ==================== */
.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* ==================== BUDGET DASHBOARD (TOP CARDS) ==================== */
.budget-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.budget-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.budget-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.budget-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.budget-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.budget-card-title {
    font-size: 14px;
    color: var(--text-gray);
    font-weight: 500;
}

.budget-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.budget-card:nth-child(1) .budget-card-icon {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
}

.budget-card:nth-child(2) .budget-card-icon {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.budget-card:nth-child(3) .budget-card-icon {
    background: linear-gradient(135deg, #10b981, #14b8a6);
}

.budget-card-amount {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
}

.budget-card-subtitle {
    font-size: 13px;
    color: var(--text-gray);
    margin-bottom: 16px;
}

/* ==================== PROGRESS BARS ==================== */
.budget-progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 16px;
}

.budget-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #14b8a6);
    border-radius: 999px;
    transition: width 0.6s ease;
}

.budget-progress-bar.over-budget {
    background: linear-gradient(90deg, #ef4444, #f59e0b);
}

/* ==================== BUDGET INPUT ==================== */
.budget-input-container {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.budget-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px 16px;
    color: white;
    font-size: 14px;
}

.budget-input:focus {
    outline: none;
    border-color: var(--primary-purple);
    background: rgba(255, 255, 255, 0.15);
}

.update-budget-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--success-green);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.update-budget-btn:hover {
    transform: scale(1.05);
}

/* ==================== PIE CHART SECTION ==================== */
.tips-title,
.templates-title,
.expense-list-title,
.charts-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==================== CHART BARS ==================== */
.chart-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-bar-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chart-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-gray);
}

.chart-bar-icon {
    margin-right: 8px;
    font-size: 18px;
}

.chart-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s ease;
    position: relative;
}

.chart-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

/* ==================== EXPENSE LIST ==================== */
.expense-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.expense-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.expense-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

.expense-category-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.expense-details {
    flex: 1;
}

.expense-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.expense-meta {
    font-size: 13px;
    color: var(--text-gray);
    display: flex;
    gap: 12px;
}

.expense-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-pink);
}

.expense-delete {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.expense-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.1);
}

/* ==================== TEMPLATES ==================== */
.templates-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.template-card {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.template-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.template-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.template-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.template-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-purple);
    margin-bottom: 4px;
}

.template-description {
    font-size: 12px;
    color: var(--text-gray);
}

/* ==================== TIPS SECTION ==================== */
.tips-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.tips-navigation {
    display: flex;
    gap: 8px;
}

.tips-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.tips-nav-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.tips-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-gray);
}

/* ==================== LOADING ==================== */
.budget-tracker-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 20px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==================== ANIMATIONS ==================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .budget-app-layout {
        grid-template-columns: 1fr;
    }
    
    .budget-sidebar {
        order: 2;
    }
}

@media (max-width: 768px) {
    .budget-dashboard {
        grid-template-columns: 1fr;
    }
    
    .budget-header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
    }
    
    .header-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==================== RTL SUPPORT ==================== */
[dir="rtl"] .budget-app-layout {
    direction: rtl;
}

[dir="rtl"] .expense-item:hover {
    transform: translateX(-4px);
}

[dir="rtl"] .chart-bar-icon {
    margin-right: 0;
    margin-left: 8px;
}
/* ==================== LAYOUT FIX - ADD THIS TO END OF budget-tracker.css ==================== */

/* Budget App Main Container */
.budget-app {
    max-width: 1600px;
    margin: 0 auto;
}

/* Two Column Layout - Main content + Sidebar */
.budget-app-layout {
    display: grid;
    grid-template-columns: 1fr 380px; /* Main content LEFT, Sidebar RIGHT */
    gap: 24px;
    margin-top: 24px;
    align-items: flex-start;
}

/* Main content area */
.budget-main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Sidebar */
.budget-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* RTL: Reverse columns (Sidebar LEFT, Main content RIGHT) */
.budget-app-layout.rtl-layout {
    grid-template-columns: 380px 1fr;
}

/* Responsive: Stack vertically on tablets/mobile */
@media (max-width: 1024px) {
    .budget-app-layout,
    .budget-app-layout.rtl-layout {
        grid-template-columns: 1fr;
    }
    
    .budget-sidebar {
        order: 1;
    }
    
    .budget-main-content {
        order: 2;
    }
}
/* Restore Clickability - Override WP/Theme Blocks */
#budget-tracker-container,
.budget-app,
.budget-header,
.budget-app-layout,
.glass-card,
.tab-button,
.dropdown-button,
.btn,
.form-input,
.category-option,
.expense-delete {
    pointer-events: auto !important;
    z-index: auto !important;
    cursor: pointer !important;
}

.dropdown-menu {
    pointer-events: auto;
    z-index: 999 !important;  /* Above everything */
}

.dropdown.active .dropdown-menu {
    display: block !important;  /* Force show on toggle */
}

/* RTL Safe */
.rtl-layout .budget-header { direction: rtl; }
/* Z-Index Fix: Menus Above All (From Screenshot Analysis) */
.budget-app {
    position: relative;  /* Establish stacking context */
    z-index: 1 !important;
}

.budget-header {
    position: sticky;  /* Stick to top */
    top: 0;
    z-index: 1000 !important;  /* Header highest - dropdowns won't hide behind dashboard */
    pointer-events: auto !important;
}

.header-controls {
    z-index: 1001 !important;  /* Controls container above header */
}

.dropdown {
    position: relative;  /* Relative for absolute dropdown-menu */
    z-index: 1002 !important;
}

.dropdown-button {
    position: relative;
    z-index: 1003 !important;  /* Button clickable above all */
}

.dropdown-menu {
    position: absolute !important;
    top: 100%;  /* Below button */
    left: 0;
    right: 0;
    z-index: 1004 !important;  /* Highest - pops above dashboard/tabs/sidebar */
    background: rgba(30, 58, 138, 0.95);  /* Match glassmorphism */
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);  /* Elevated shadow */
    opacity: 1;  /* Ensure visible */
    display: none;  /* Hidden until .active */
}

.dropdown.active .dropdown-menu {
    display: block !important;  /* Show on toggle - no z-index hide */
}

.dropdown-menu-item {
    z-index: 1005 !important;  /* Items highest within menu */
    position: relative;
}

/* Tabs Z-Index (Below Header, Above Content) */
.tabs-menu {
    position: sticky;
    z-index: 200 !important;  /* Mid-layer - above dashboard but below dropdowns */
    pointer-events: auto !important;
}

.tab-button {
    position: relative;
    z-index: 201 !important;  /* Tabs clickable, no overlap from cards */
    background: rgba(59, 130, 246, 0.8);  /* Slight elevation */
}

.tab-button.active {
    z-index: 202 !important;  /* Active tab highest */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);  /* Visual lift */
}

/* Dashboard/Sidebar Z-Index (Base Layer) */
.budget-dashboard-container,
.budget-sidebar,
.glass-card {
    position: relative;
    z-index: 50 !important;  /* Low - below menus/tabs */
}

#tab-content-container {
    z-index: 10 !important;  /* Content lowest */
    pointer-events: auto !important;
}

/* Global Overrides (WP Theme Interference) */
#budget-tracker-container * {
    -webkit-overflow-scrolling: touch;  /* iOS scroll fix */
}

.budget-app-layout {
    overflow: visible !important;  /* Prevent clipping dropdowns */
}

/* RTL Z-Index Safe (For Hebrew/Arabic) */
.rtl-layout .dropdown-menu {
    left: auto !important;
    right: 0 !important;
}
