/* Variables de CSS - Premium Dark Theme */
:root {
    --bg-color: #0f1115; /* Fondo principal oscuro profundo */
    --surface-color: rgba(30, 33, 40, 0.6); /* Glassmorphism surface */
    --surface-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    
    --primary-color: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    
    --success-color: #10b981; /* Esmeralda para ingresos */
    --danger-color: #ef4444; /* Rojo para gastos */
    
    --blue: #3b82f6;
    --orange: #f59e0b;
    --pink: #ec4899;
    --green: #10b981;
    
    --font-family: 'Inter', sans-serif;
    --border-radius: 16px;
    --border-radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.mb-24 { margin-bottom: 24px; }

/* Glassmorphism Utilities */
.glass-card {
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.glass-form {
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 24px;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

.section-title {
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

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

/* Screens Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Login Screen */
#login-screen {
    display: none; /* hidden by default, JS handles active class */
    place-items: center;
}

#login-screen.active {
    display: grid;
}

.login-container {
    text-align: center;
    padding: 40px;
    max-width: 400px;
    width: 90%;
}

.login-container h1 {
    font-size: 2rem;
    margin: 16px 0 8px;
}

.login-container p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.logo-wrapper {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

/* Layout */
#app-screen.active {
    display: flex;
}

.sidebar {
    width: 260px;
    background: rgba(20, 23, 28, 0.8);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    display: none; /* Hidden on mobile */
}

.main-content {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    padding-bottom: 100px; /* Space for bottom nav on mobile */
    width: 100%;
}

/* Views Management */
.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

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

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 8px;
    border-radius: 50%;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.w-100 { width: 100%; }

/* Mobile Header */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.avatar.hidden {
    display: none;
}

.greeting {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-name-title {
    font-size: 1.1rem;
    margin: 0;
}

/* Balance Card */
.balance-card {
    text-align: center;
    background: linear-gradient(145deg, rgba(30, 33, 40, 0.8), rgba(20, 23, 28, 0.9));
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 60%);
    pointer-events: none;
}

.balance-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.balance-card h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: -0.05em;
}

.balance-stats {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--surface-border);
    padding-top: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.stat i {
    font-size: 2rem;
}

.stat.income i { color: var(--success-color); }
.stat.expense i { color: var(--danger-color); }

.stat span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat h3 {
    font-size: 1.1rem;
    margin: 0;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-btn {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    min-width: 70px;
}

.quick-btn:hover {
    transform: translateY(-4px);
}

.icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.quick-btn span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

/* Transactions List */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.transaction-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tx-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tx-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(255,255,255,0.05);
}

.tx-details h4 {
    margin: 0;
    font-size: 1rem;
}

.tx-details p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tx-amount {
    font-weight: 600;
    font-size: 1.1rem;
}

.tx-amount.expense { color: var(--text-primary); }
.tx-amount.income { color: var(--success-color); }

.view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Budget Status List */
.budget-status-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.budget-item {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.budget-item-info {
    flex: 1;
}

.budget-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.budget-item-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.budget-item-amounts {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.progress-bar-bg {
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.btn-check-budget {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-check-budget:hover:not(:disabled) {
    background: var(--success-color);
    color: white;
    transform: scale(1.05);
}

.btn-check-budget:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-check-budget.completed {
    background: var(--success-color);
    color: white;
    cursor: default;
}

/* Form Styles */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

input, .custom-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 14px 16px;
    color: white;
    font-size: 1rem;
    font-family: var(--font-family);
    transition: var(--transition);
}

.custom-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.custom-select option {
    background-color: var(--bg-color);
    color: white;
}

input:focus, .custom-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.amount-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

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

#tx-amount, #quick-amount {
    font-size: 2rem;
    font-weight: 700;
    padding-left: 40px;
    height: 70px;
}

.transaction-type-selector {
    display: flex;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 24px;
}

.type-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.type-btn.active {
    background: var(--surface-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.type-btn.active[data-type="expense"] { color: #ef4444; border-bottom: 2px solid #ef4444; }
.type-btn.active[data-type="income"] { color: #10b981; border-bottom: 2px solid #10b981; }


/* Bottom Navigation (Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(20, 23, 28, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 0 24px; /* Extra padding for iOS home indicator */
    z-index: 100;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    transition: var(--transition);
    width: 60px;
}

.bottom-nav .nav-item i {
    font-size: 1.5rem;
}

.bottom-nav .nav-item.active {
    color: var(--primary-color);
}

.add-btn-wrapper {
    position: relative;
    top: -20px;
}

.add-btn {
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
    border: 4px solid var(--bg-color);
    transition: var(--transition);
}

.nav-item.active .add-btn {
    transform: scale(1.1);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    place-items: center;
}

.modal.active {
    display: grid;
    animation: fadeIn 0.2s;
}

.modal-content {
    width: 90%;
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* History View */
.month-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.history-summary {
    display: flex;
    justify-content: space-around;
    margin-bottom: 24px;
}

.history-summary .stat {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Categorias de Settings */
.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-color);
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
}

.category-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cat-icon-display {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(30, 33, 40, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    color: white;
    padding: 16px 32px;
    border-radius: 100px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    transform: translateY(-150%);
    animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, slideUp 0.4s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards 3.5s;
}

.toast.success { border-bottom: 4px solid var(--success-color); }
.toast.error { border-bottom: 4px solid var(--danger-color); }
.toast i { font-size: 1.5rem; }
.toast.success i { color: var(--success-color); }
.toast.error i { color: var(--danger-color); }

@keyframes slideDown {
    to { transform: translateY(0); }
}
@keyframes slideUp {
    to { transform: translateY(-150%); opacity: 0; }
}

/* Media Query for Desktop */
@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
    
    .sidebar {
        display: flex;
    }
    
    .mobile-header {
        display: none;
    }
    
    .main-content {
        padding: 40px;
        max-width: 900px;
    }
    
    .sidebar-header {
        padding: 32px 24px;
    }
    
    .sidebar-header .logo {
        font-size: 1.25rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .sidebar-header .logo i {
        color: var(--primary-color);
        font-size: 1.5rem;
    }
    
    .sidebar-nav {
        flex: 1;
        padding: 0 16px;
    }
    
    .sidebar-nav .nav-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        color: var(--text-secondary);
        text-decoration: none;
        border-radius: 12px;
        margin-bottom: 8px;
        transition: var(--transition);
        font-weight: 500;
    }
    
    .sidebar-nav .nav-item:hover {
        background: rgba(255,255,255,0.05);
        color: var(--text-primary);
    }
    
    .sidebar-nav .nav-item.active {
        background: var(--primary-color);
        color: white;
    }
    
    .sidebar-footer {
        padding: 24px;
        border-top: 1px solid var(--surface-border);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}
