/* Design System & Custom Properties */
:root {
    --bg-dark: #070a13;
    --bg-dark-rgb: 7, 10, 19;
    --bg-card: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.15);
    
    /* Brand Colors */
    --accent-cyan: #00f2fe;
    --accent-blue: #4facfe;
    --accent-purple: #7f00ff;
    --accent-indigo: #4e54c8;
    --accent-pink: #ff007f;
    --accent-green: #00f5a0;
    --accent-red: #ff3366;
    --accent-orange: #f97316;
    --accent-yellow: #fbbf24;
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Layout & Spacing */
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 12px;
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-header: 'Outfit', sans-serif;
    
    /* Shadow */
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glow-shadow: 0 0 20px rgba(79, 172, 254, 0.3);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    position: relative;
}

html {
    height: -webkit-fill-available;
}

/* Glowing Ambient Orbs */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25;
}

.orb-1 {
    top: -10%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-blue) 0%, var(--accent-purple) 100%);
}

.orb-2 {
    bottom: -10%;
    left: -10%;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, var(--accent-cyan) 0%, var(--accent-indigo) 100%);
}

/* App Container & Layout */
.app-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 24px 20px calc(40px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-logo {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-week {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.3px;
}

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.08);
}

/* ─── Glass Card Base ────────────────────────────────────────────────────── */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
}

/* ─── Main Budget Card ───────────────────────────────────────────────────── */
.budget-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-highlight);
    border-radius: var(--border-radius-lg);
    padding: 28px 24px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.budget-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue), var(--accent-purple));
}

.card-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 12px;
}

.budget-display {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 8px;
}

.budget-display .currency {
    font-family: var(--font-header);
    font-weight: 300;
    font-size: 2rem;
    color: var(--accent-blue);
    margin-top: 8px;
    margin-right: 4px;
}

.budget-display .amount {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 3.5rem;
    line-height: 1;
    letter-spacing: -1px;
    background: linear-gradient(180deg, #ffffff 40%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.budget-subtitle {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    font-weight: 500;
    margin-bottom: 24px;
    background: rgba(0, 242, 254, 0.08);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(0, 242, 254, 0.15);
}

/* ─── Progress Bar ───────────────────────────────────────────────────────── */
.progress-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

#days-remaining-badge {
    color: var(--text-secondary);
}

/* ─── Stats Overview Grid ────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-box:not(.no-action) {
    cursor: pointer;
}

.stat-box:not(.no-action):active {
    transform: translateY(2px);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-highlight);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-value {
    font-family: var(--font-header);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text-primary);
}

.stat-action {
    font-size: 0.65rem;
    color: var(--accent-blue);
    font-weight: 500;
}

/* ─── Close Day Section ──────────────────────────────────────────────────── */
.close-day-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    padding-left: 4px;
}

/* Trigger button when day is open */
.close-day-trigger-btn {
    width: 100%;
    background: linear-gradient(135deg, rgba(127, 0, 255, 0.12) 0%, rgba(79, 172, 254, 0.08) 100%);
    border: 1px solid rgba(127, 0, 255, 0.25);
    border-radius: var(--border-radius-md);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.close-day-trigger-btn:active {
    transform: scale(0.98);
    border-color: var(--accent-purple);
    background: rgba(127, 0, 255, 0.18);
}

.close-day-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.close-day-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-grow: 1;
}

.close-day-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.close-day-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.close-day-arrow {
    font-size: 1.2rem;
    color: var(--accent-purple);
    flex-shrink: 0;
}

/* When day is already closed */
.today-closed {
    width: 100%;
    background: linear-gradient(135deg, rgba(0, 245, 160, 0.08) 0%, rgba(0, 242, 254, 0.04) 100%);
    border: 1px solid rgba(0, 245, 160, 0.2);
    border-radius: var(--border-radius-md);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.today-closed-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.today-closed-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-grow: 1;
}

.today-closed-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-green);
}

.today-closed-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.today-closed-balance {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ─── Weekly Log ─────────────────────────────────────────────────────────── */
.week-log-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.week-log-list {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Each day row */
.week-day-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.week-day-item:last-child {
    border-bottom: none;
}

.week-day-item.today {
    background: rgba(79, 172, 254, 0.06);
    border-left: 3px solid var(--accent-blue);
}

.week-day-item.future {
    opacity: 0.55;
}

.wdi-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.wdi-day {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.today-tag {
    font-size: 0.6rem;
    font-weight: 700;
    background: var(--accent-blue);
    color: #fff;
    padding: 2px 6px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.wdi-budget-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.wdi-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.wdi-expense {
    font-size: 0.9rem;
    font-weight: 700;
}

.wdi-expense.good {
    color: var(--accent-green);
}

.wdi-expense.warning {
    color: var(--accent-yellow);
}

.wdi-expense.over-budget {
    color: var(--accent-red);
}

.wdi-expense.today-budget {
    color: var(--accent-blue);
}

.wdi-expense.future-amount {
    color: var(--text-muted);
}

.wdi-balance {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 5, 10, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 480px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.94, 0.6, 1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-title {
    font-family: var(--font-header);
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: -12px;
}

/* ─── Inputs ─────────────────────────────────────────────────────────────── */
.input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.input-currency {
    position: absolute;
    left: 16px;
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-wrapper input[type="number"] {
    width: 100%;
    padding: 16px 16px 16px 40px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-wrapper input[type="number"]:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.1);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 14px 20px;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.98);
}

.primary-btn {
    background: linear-gradient(90deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(127, 0, 255, 0.2);
}

.primary-btn:active {
    opacity: 0.9;
}

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

.secondary-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.danger-btn {
    background: rgba(255, 51, 102, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(255, 51, 102, 0.25);
    white-space: nowrap;
}

.danger-btn:active {
    background: rgba(255, 51, 102, 0.2);
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 12px;
    margin-top: 8px;
}

/* ─── Config UI ──────────────────────────────────────────────────────────── */
.config-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.config-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.config-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.config-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translate(-50%, 100px);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    transform: translate(-50%, 0);
}

/* ─── Desktop Adjustments ────────────────────────────────────────────────── */
@media (min-width: 480px) {
    .app-container {
        border-left: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
        background: rgba(7, 10, 19, 0.6);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    }
    
    .modal-content {
        border-radius: var(--border-radius-lg);
        margin-bottom: 24px;
    }
    
    .modal-overlay {
        align-items: center;
    }
    
    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }
}
