/* ============================================
   Budget Analyzer - Styles
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.step-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Bank Selection Grid */
.bank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.bank-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.bank-btn:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.bank-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.bank-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: white;
}

.chase-icon { background: linear-gradient(135deg, #117aca, #0a4f8a); }
.wf-icon { background: linear-gradient(135deg, #d71e28, #a0161d); }
.bofa-icon { background: linear-gradient(135deg, #e31837, #012169); }
.usaa-icon { background: linear-gradient(135deg, #1b3a5c, #0d2137); }

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    margin-bottom: 0.75rem;
}

.upload-text {
    font-size: 1.05rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.upload-subtext {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.upload-formats {
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.7;
}

/* File Info */
.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-top: 1rem;
}

.file-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.btn-remove:hover {
    color: var(--danger);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: 1rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Privacy Note */
.privacy-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(16, 185, 129, 0.08);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--success);
}

/* Summary Bar */
.summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.summary-item {
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.summary-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
}

.summary-value.income { color: var(--success); }
.summary-value.expense { color: var(--danger); }

/* Charts */
.chart-section {
    margin: 1.5rem 0;
}

.chart-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.chart-container {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
}

.chart-row {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.chart-container-half {
    position: relative;
    width: 250px;
    text-align: center;
}

.chart-label {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Tier Tabs */
.tier-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tier-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.tier-tab:hover {
    color: var(--text);
}

.tier-tab.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

.tier-icon {
    font-size: 1.1rem;
}

/* Tier Content */
.tier-description {
    padding: 0.75rem 1rem;
    background: rgba(99, 102, 241, 0.08);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.savings-target {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.savings-target .label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.savings-target .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
}

/* Budget Table */
.budget-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.budget-table th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.budget-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.budget-table tr:last-child td {
    border-bottom: none;
    font-weight: 700;
}

.budget-table .category-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.change-negative {
    color: var(--danger);
    font-weight: 600;
}

.change-positive {
    color: var(--success);
    font-weight: 600;
}

.change-neutral {
    color: var(--text-muted);
}

/* Action Bar */
.action-bar {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.action-bar .btn-primary {
    flex: 1;
    min-width: 150px;
    margin-top: 0;
}

.action-bar .btn-secondary {
    flex: 1;
    min-width: 120px;
}

/* Transaction Details */
.txn-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.25rem 0;
    list-style: none;
}

.txn-summary::-webkit-details-marker {
    display: none;
}

.txn-summary h3 {
    font-size: 1rem;
    font-weight: 600;
}

.txn-toggle {
    font-size: 0.8rem;
    color: var(--primary-light);
}

.txn-filters {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.txn-filters select,
.txn-filters input {
    flex: 1;
    min-width: 150px;
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.875rem;
}

.txn-filters select:focus,
.txn-filters input:focus {
    outline: none;
    border-color: var(--primary);
}

.txn-table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.txn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.txn-table th {
    text-align: left;
    padding: 0.625rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.txn-table td {
    padding: 0.625rem;
    border-bottom: 1px solid var(--border);
}

.txn-table .amount-positive { color: var(--success); }
.txn-table .amount-negative { color: var(--danger); }

.txn-category-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 640px) {
    .app-container {
        padding: 1rem 0.75rem;
    }

    .card {
        padding: 1.25rem;
    }

    .bank-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-row {
        flex-direction: column;
        align-items: center;
    }

    .tier-tab {
        font-size: 0.8rem;
        padding: 0.625rem 0.5rem;
    }

    .action-bar {
        flex-direction: column;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: #1a1a1a;
    }

    .app-container {
        max-width: 100%;
    }

    .card {
        background: white;
        border: 1px solid #ddd;
        box-shadow: none;
        break-inside: avoid;
    }

    #step1, #step2, .action-bar, .privacy-note, .upload-zone, .app-footer {
        display: none !important;
    }

    .tier-tabs {
        display: none;
    }

    .summary-value.income { color: #059669; }
    .summary-value.expense { color: #dc2626; }
}
