/* -------------------------------------------------------
    GLOBAL STYLES
-------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    transition: 0.3s ease-in-out;
}

/* Light Theme */
:root {
    --bg: #f5f5f5;
    --card: #ffffff;
    --text: #222;
    --primary: #4b7bec;
    --secondary: #3867d6;
    --success: #20bf6b;
    --warning: #fa8231;
    --danger: #eb3b5a;
    --border: #dcdcdc;
    --shadow: rgba(0,0,0,0.1);
}

/* Dark Theme */
body.dark {
    --bg: #111;
    --card: #1b1b1b;
    --text: #eaeaea;
    --primary: #4b7bec;
    --secondary: #3867d6;
    --success: #20bf6b;
    --warning: #fa8231;
    --danger: #eb3b5a;
    --border: #333;
    --shadow: rgba(0,0,0,0.3);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}



/* -------------------------------------------------------
    AUTH (LOGIN & REGISTER)
-------------------------------------------------------- */
.auth-container {
    background: var(--card);
    padding: 40px;
    width: 90%;
    max-width: 380px;
    border-radius: 8px;
    box-shadow: 0 0 10px var(--shadow);
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
}

.auth-container h3 {
    text-align: center;
    margin-bottom: 20px;
    font-weight: normal;
    color: var(--text);
}

.auth-container input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.auth-container button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.auth-container button:hover {
    opacity: 0.9;
}

.switch-auth {
    margin-top: 15px;
    font-size: 14px;
    text-align: center;
}

.switch-auth a {
    color: var(--primary);
    text-decoration: none;
}



/* -------------------------------------------------------
    MAIN APP LAYOUT
-------------------------------------------------------- */
#app {
    padding-top: 60px; /* top bar spacing */
    padding-bottom: 70px; /* navbar spacing */
}

/* TOP BAR */
#topbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: var(--card);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    z-index: 20;
    box-shadow: 0 2px 4px var(--shadow);
}

#topbar h2 {
    font-size: 22px;
    color: var(--primary);
    font-weight: bold;
}

#settings-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

#settings-btn:hover {
    background: var(--secondary);
}



/* -------------------------------------------------------
    NAVBAR
-------------------------------------------------------- */
#navbar {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--card);
    padding: 10px;
    display: flex;
    justify-content: space-around;
    border-top: 1px solid var(--border);
    z-index: 10;
    box-shadow: 0 -2px 4px var(--shadow);
}

.nav-btn {
    padding: 10px 15px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.nav-btn:hover {
    color: var(--primary);
    background: var(--bg);
}

.nav-btn.active {
    color: var(--primary);
    background: var(--bg);
    font-weight: bold;
}

.nav-btn i {
    font-size: 16px;
}



/* -------------------------------------------------------
    SECTIONS & CARDS
-------------------------------------------------------- */
.section {
    padding: 20px;
    padding-bottom: 20px;
}

.card {
    background: var(--card);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}

.card h3 {
    margin-bottom: 15px;
    color: var(--text);
    font-size: 18px;
}





/* -------------------------------------------------------
    HOME SECTION SPECIFIC STYLES
-------------------------------------------------------- */
.welcome-card {
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
}

.welcome-card h3 {
    color: white;
    font-size: 20px;
    margin-bottom: 10px;
}

.welcome-card p {
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.4;
}

/* Budget Card Styles */
.budget-card h3 {
    color: var(--text);
    margin-bottom: 20px;
}

.budget-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 15px;
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 15px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text);
    opacity: 0.7;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: bold;
}

.stat-amount {
    display: block;
    font-size: 20px;
    font-weight: bold;
    color: var(--text);
}

.stat-amount.remaining {
    color: var(--success);
}

/* Progress Bar */
.progress-container {
    margin-top: 15px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    font-size: 12px;
    color: var(--text);
    opacity: 0.7;
}

/* Quick Stats Card */
.quick-stats-card h3 {
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-box {
    text-align: center;
    padding: 15px 10px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
}

.stat-box:hover {
    transform: translateY(-2px);
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-desc {
    font-size: 11px;
    color: var(--text);
    opacity: 0.7;
    text-transform: uppercase;
    font-weight: bold;
}



/* -------------------------------------------------------
    TABLE (Dashboard)
-------------------------------------------------------- */
#expense-table {
    width: 100%;
    border-collapse: collapse;
}

#expense-table th, #expense-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

#expense-table th {
    text-align: left;
    font-weight: bold;
}


/* -------------------------------------------------------
    CREATE PLAN SECTION STYLES
-------------------------------------------------------- */
.section-description {
    color: var(--text);
    opacity: 0.7;
    margin-bottom: 25px;
    font-size: 14px;
    line-height: 1.4;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(75, 123, 236, 0.1);
}

.form-hint {
    font-size: 12px;
    color: var(--text);
    opacity: 0.6;
    margin-top: 5px;
}

/* Form Row for side-by-side inputs */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Checkbox Styles */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Plan Preview */
.plan-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}

.plan-preview h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.preview-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.preview-item span:first-child {
    font-weight: bold;
    color: var(--text);
    opacity: 0.8;
}

.preview-item span:last-child {
    color: var(--text);
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease;
}

.submit-btn:hover {
    background: var(--secondary);
}

.submit-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

/* Existing Plans List */
.existing-plan-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plan-info h4 {
    margin-bottom: 5px;
    color: var(--text);
}

.plan-details {
    font-size: 12px;
    color: var(--text);
    opacity: 0.7;
}

.plan-amount {
    font-weight: bold;
    color: var(--primary);
    font-size: 16px;
}

.empty-state {
    text-align: center;
    color: var(--text);
    opacity: 0.5;
    font-style: italic;
    padding: 20px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .existing-plan-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .plan-amount {
        align-self: flex-end;
    }
}



/* -------------------------------------------------------
    ADD EXPENSE FORM
-------------------------------------------------------- */
#expense-form input,
#expense-form select {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

#expense-form button {
    width: 100%;
    background: var(--primary);
    padding: 12px;
    color: white;
    border: none;
    border-radius: 6px;
}




/* -------------------------------------------------------
    SETTINGS PANEL - REDESIGNED
-------------------------------------------------------- */
#settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: var(--card);
    border-left: 1px solid var(--border);
    padding: 20px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.settings-content {
    flex: 1;
}

.settings-content h3 {
    margin-bottom: 25px;
    color: var(--primary);
    font-size: 22px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}

.settings-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.settings-section:last-of-type {
    border-bottom: none;
}

.settings-section h4 {
    margin-bottom: 15px;
    color: var(--text);
    font-size: 16px;
}

.settings-section h5 {
    margin: 15px 0 10px;
    color: var(--text);
    font-size: 14px;
    opacity: 0.8;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.theme-toggle span {
    font-weight: 500;
    color: var(--text);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 120px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary);
    border-radius: 34px;
    transition: .4s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background: white;
    border-radius: 50%;
    transition: .4s;
    z-index: 2;
}

input:checked + .toggle-slider {
    background: var(--secondary);
}

input:checked + .toggle-slider:before {
    transform: translateX(86px);
}

.toggle-label {
    font-size: 12px;
    font-weight: bold;
    color: white;
    z-index: 1;
    transition: opacity 0.3s;
}

.toggle-label.light {
    opacity: 1;
}

.toggle-label.dark {
    opacity: 0.5;
}

input:checked + .toggle-slider .toggle-label.light {
    opacity: 0.5;
}

input:checked + .toggle-slider .toggle-label.dark {
    opacity: 1;
}

/* Form Elements in Settings */
.settings-content input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.settings-content input:disabled {
    background: var(--card);
    opacity: 0.6;
    cursor: not-allowed;
}

.settings-content input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(75, 123, 236, 0.2);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text);
    opacity: 0.6;
    margin-top: -8px;
    margin-bottom: 12px;
}

/* Buttons in Settings */
#update-profile-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

#update-profile-btn:hover {
    background: var(--secondary);
}

#update-profile-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: #d63031;
}

.close-btn {
    width: 100%;
    padding: 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s;
}

.close-btn:hover {
    background: var(--border);
}

/* Success/Error Messages */
#settings-message {
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    text-align: center;
    font-size: 14px;
    display: none;
}

#settings-message.success {
    background: rgba(32, 191, 107, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
    display: block;
}

#settings-message.error {
    background: rgba(235, 59, 90, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
    display: block;
}

/* Responsive Settings */
@media (max-width: 480px) {
    #settings-panel {
        width: 100%;
    }
}



/* -------------------------------------------------------
    RESPONSIVE DESIGN
-------------------------------------------------------- */
@media (min-width: 768px) {
    .section {
        max-width: 600px;
        margin: 0 auto;
    }
    
    .budget-stats {
        gap: 20px;
    }
    
    .stats-grid {
        gap: 15px;
    }
    
    .nav-btn {
        font-size: 14px;
        padding: 12px 20px;
    }
}


/* Currency Display in Settings */
.currency-display {
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
}

.currency-display strong {
    display: block;
    color: var(--text);
    margin-bottom: 5px;
}

.currency-display small {
    color: var(--text);
    opacity: 0.7;
    font-size: 12px;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    color: white;
    font-size: 18px;
    font-weight: bold;
}


/* Delete Button Styles */
.delete-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.delete-btn:hover {
    background: #d63031;
    transform: scale(1.05);
}

/* Action cell in table */
.action-cell {
    text-align: center;
    width: 80px;
}

/* Plan item with delete button */
.existing-plan-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative; /* For delete button positioning */
}

.plan-actions {
    display: flex;
    gap: 8px;
}

.delete-plan-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.delete-plan-btn:hover {
    background: #d63031;
}


/* Confirmation Modal */
#confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.modal-content {
    background: var(--card);
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

#confirm-cancel {
    background: var(--bg);
    color: var(--text);
}

#confirm-ok {
    background: var(--danger);
    color: white;
}



/* -------------------------------------------------------
   SIMPLE NOTIFICATION
-------------------------------------------------------- */
#simple-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-weight: 500;
    font-size: 14px;
    max-width: 300px;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-success {
    background: var(--success);
    color: white;
    border-left: 4px solid #1a9950;
}

.notification-error {
    background: var(--danger);
    color: white;
    border-left: 4px solid #c53030;
}

.notification-info {
    background: var(--primary);
    color: white;
    border-left: 4px solid #2d5aa0;
}

.notification-warning {
    background: var(--warning);
    color: white;
    border-left: 4px solid #e67e22;
}