/* Budget Tracker Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

#app {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: white;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Setup Page Styles */
.setup-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.setup-container {
    max-width: 500px;
    width: 100%;
}

.setup-card {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.setup-card h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #667eea;
}

.setup-description {
    margin-bottom: 30px;
    color: #666;
    line-height: 1.6;
}

.security-notice {
    background: #f8f9ff;
    border: 1px solid #e3e8ff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.security-notice h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.security-notice ul {
    margin-left: 20px;
    color: #666;
}

.security-notice li {
    margin-bottom: 5px;
}

.setup-form {
    text-align: left;
}

/* Login Styles */
.login-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    display: grid;
    place-items: center !important;
    padding: 20px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    z-index: 999 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    inset: 0 !important;
}

.login-card {
    background: white !important;
    border-radius: 15px !important;
    padding: 40px !important;
    max-width: 400px !important;
    width: 100% !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important;
    text-align: center !important;
    margin: 0 auto !important;
    flex-shrink: 0 !important;
    position: relative !important;
    pointer-events: auto !important;
}

.login-card * {
    pointer-events: auto !important;
}

.login-card h1 {
    font-size: 2.2em;
    margin-bottom: 30px;
    color: #667eea;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 14px;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.setup-button,
.login-button {
    width: 100%;
    padding: 15px;
    margin-top: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.setup-button:hover,
.login-button:hover {
    transform: translateY(-2px);
}

.setup-button:disabled,
.login-button:disabled {
    opacity: 0.6;
    transform: none;
    cursor: not-allowed;
}

/* Main Application Layout */
.app-header {
    background: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    color: #333;
    font-size: 1.8em;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.app-nav {
    background: #f8f9fa;
    padding: 0 30px;
    display: flex;
    gap: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.nav-btn {
    background: none;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.nav-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

.app-main {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

/* View Management */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

/* Card Styles */
.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.card h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

/* Income Card */
.income-amount {
    font-size: 2.5em;
    font-weight: 700;
    color: #28a745;
    margin-bottom: 10px;
}

.income-method {
    color: #666;
    font-size: 14px;
}

/* Surplus Card */
.surplus-amount {
    font-size: 2.2em;
    font-weight: 700;
    margin-bottom: 10px;
}

.surplus-amount.positive {
    color: #28a745;
}

.surplus-amount.negative {
    color: #dc3545;
}

.surplus-status {
    font-size: 14px;
    font-weight: 500;
}

.surplus-status.positive {
    color: #28a745;
}

.surplus-status.negative {
    color: #dc3545;
}

/* Category Cards */
.category-amounts {
    margin-bottom: 15px;
}

.category-amounts > div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.budgeted {
    color: #666;
}

.actual {
    font-weight: 600;
    color: #333;
}

.difference {
    font-weight: 700;
}

.difference.positive {
    color: #28a745;
}

.difference.negative {
    color: #dc3545;
}

.three-month-info {
    font-size: 12px;
    margin-top: 8px;
    font-style: italic;
}

.three-month-info.positive {
    color: #28a745;
}

.three-month-info.negative {
    color: #dc3545;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.8s ease;
    border-radius: 4px;
}

.progress-fill.over-budget {
    background: linear-gradient(90deg, #dc3545, #c82333);
}

/* Recommendations */
.recommendations-card {
    grid-column: 1 / -1;
}

.recommendation {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    font-size: 14px;
}

.recommendation.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.recommendation.warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.recommendation.alert {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.recommendation.opportunity {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.recommendation.recent-improvement {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.recommendation.recent-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #007bff;
}

.recommendation.recent-concern {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #fd7e14;
}

.three-month-surplus {
    font-size: 12px;
    margin-top: 8px;
    font-style: italic;
}

.three-month-surplus.positive {
    color: #28a745;
}

.three-month-surplus.negative {
    color: #dc3545;
}

/* Subscriptions View */
.subscriptions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.subscriptions-header h2 {
    color: #333;
    font-size: 1.8em;
}

.subscriptions-summary {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    text-align: center;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-item .label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.summary-item .value {
    font-size: 1.5em;
    font-weight: 700;
    color: #333;
}

.summary-item.total .value {
    color: #667eea;
}

.subscriptions-list {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.subscription-group {
    margin-bottom: 0;
}

.group-title {
    background: #f8f9fa;
    padding: 20px 25px;
    color: #333;
    font-size: 1.1em;
    font-weight: 600;
    margin: 0;
    border-bottom: 1px solid #e9ecef;
}

.subscription-item {
    display: flex;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.3s ease;
}

.subscription-item:hover {
    background: #f8f9fa;
}

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

.subscription-main {
    flex: 1;
}

.subscription-name {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.subscription-amount {
    font-size: 1.2em;
    font-weight: 700;
    color: #667eea;
}

.subscription-details {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 0 20px;
    font-size: 14px;
    color: #666;
}

.subscription-details span {
    background: #f8f9fa;
    padding: 4px 12px;
    border-radius: 20px;
}

.subscription-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.btn-icon:hover {
    background: #e9ecef;
}

.btn-icon.delete:hover {
    background: #f8d7da;
}

.no-subscriptions {
    padding: 40px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Settings View */
.settings-card {
    max-width: 600px;
    margin-bottom: 30px;
}

.settings-description {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.6;
}

.settings-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    align-items: end;
}

.settings-form .form-group {
    margin-bottom: 0;
}

.total-percentage {
    grid-column: 1 / -1;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: 600;
    margin: 20px 0;
}

.total-percentage.invalid {
    background: #f8d7da;
    color: #721c24;
}

.total-percentage.valid {
    background: #d4edda;
    color: #155724;
}

.settings-form button {
    grid-column: 1 / -1;
}

.income-info-card {
    max-width: 600px;
}

.income-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.income-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.income-stat .label {
    font-weight: 600;
    color: #666;
}

.income-stat .value {
    font-weight: 700;
    color: #333;
}

.income-breakdown h4 {
    margin-bottom: 15px;
    color: #333;
}

.breakdown-list {
    display: grid;
    gap: 8px;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f8f9fa;
}

.breakdown-item .month {
    font-weight: 500;
    color: #666;
}

.breakdown-item .amount {
    font-weight: 600;
    color: #333;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 25px 30px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.4em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #333;
}

.modal-form {
    padding: 30px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Status Messages */
.status-message {
    padding: 12px 20px;
    border-radius: 8px;
    margin: 15px 0;
    font-weight: 500;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1001;
    max-width: 400px;
}

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

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

.toast.warning {
    background: #ffc107;
    color: #333;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 15px 20px;
    }
    
    .app-header h1 {
        font-size: 1.4em;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .header-actions .btn {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .app-nav {
        padding: 0 20px;
        overflow-x: auto;
    }
    
    .nav-btn {
        padding: 12px 16px;
        font-size: 14px;
        white-space: nowrap;
    }
    
    .app-main {
        padding: 20px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .card {
        padding: 20px;
    }
    
    .income-amount {
        font-size: 2em;
    }
    
    .surplus-amount {
        font-size: 1.8em;
    }
    
    .subscriptions-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .subscriptions-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 20px;
    }
    
    .subscription-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .subscription-details {
        margin: 0;
    }
    
    .settings-form {
        grid-template-columns: 1fr;
    }
    
    .income-summary {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .modal-form {
        padding: 20px;
    }
    
    .toast {
        right: 20px;
        left: 20px;
        bottom: 20px;
        transform: translateY(100px);
    }
    
    .toast.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .setup-card,
    .login-card {
        padding: 30px 20px;
    }
    
    .security-notice {
        padding: 15px;
    }
    
    .app-nav {
        padding: 0 15px;
    }
    
    .app-main {
        padding: 15px;
    }
    
    .card {
        padding: 15px;
    }
    
    .subscriptions-summary {
        grid-template-columns: 1fr;
        text-align: left;
    }
    
    .summary-item {
        flex-direction: row;
        justify-content: space-between;
    }
}