/* Wash Sale Tracker - Modern UI Styles */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 56px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.brand-icon {
    font-size: 1.5rem;
}

.brand-logo {
    height: 30px;
    width: 30px;
    object-fit: contain;
    border-radius: 6px;
}

.nav-links {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-wrap: nowrap;
}

.nav-link {
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

.nav-link:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.nav-link.active {
    color: var(--primary);
    font-weight: 600;
    background: rgba(37, 99, 235, 0.08);
    border-bottom: 2px solid var(--primary);
    border-radius: 6px 6px 0 0;
}

/* Hamburger menu toggle — hidden on desktop, shown on mobile */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
}

.menu-bar {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Animate hamburger to X when open */
.menu-toggle.active .menu-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.menu-toggle.active .menu-bar:nth-child(2) {
    opacity: 0;
}
.menu-toggle.active .menu-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

/* Page Header */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-header .subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

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

.card-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.card-danger {
    border-left: 4px solid var(--danger);
}

.card-danger .card-header {
    background: #fef2f2;
}

.card-muted {
    opacity: 0.8;
}

.card-muted .card-header {
    background: #f8f9fa;
}

.stat-danger {
    border-left: 4px solid var(--danger);
    background: #fef2f2;
}

.stat-muted {
    opacity: 0.7;
}

.stat-sublabel {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.row-muted {
    opacity: 0.6;
}

.empty-state-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.empty-state-inline .empty-icon {
    font-size: 1.5rem;
}

.text-muted {
    color: var(--text-muted);
    font-style: italic;
}

.card-body {
    padding: 24px;
}

/* Info Bar */
.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.info-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.info-item {
    color: var(--text-muted);
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    margin-top: 4px;
}

.status-legend {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red { background: var(--danger); }
.dot.yellow { background: var(--warning); }
.dot.green { background: var(--success); }

/* Data Table — horizontal scroll on mobile with fade indicator */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, var(--surface));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.table-container.has-scroll::after {
    opacity: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--background);
    padding: 10px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.85rem;
}

.data-table tbody tr:hover {
    background: var(--background);
}

.ticker-cell {
    font-weight: 600;
}

.amount-cell {
    font-family: 'SF Mono', Monaco, monospace;
    font-weight: 500;
}

.days-cell {
    text-align: center;
}

.account-cell {
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-option {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-long {
    background: #dcfce7;
    color: #166534;
}

.badge-short {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Cache indicator */
.cache-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    background: #e0f2fe;
    color: #0369a1;
    letter-spacing: 0.5px;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1rem;
}

.days-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.days-badge.status-red {
    background: #fee2e2;
    color: #991b1b;
}

.days-badge.status-yellow {
    background: #fef3c7;
    color: #92400e;
}

.days-badge.status-green {
    background: #dcfce7;
    color: #166534;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--background);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

/* Button loading state */
.btn-loading {
    opacity: 0.7;
    cursor: wait;
    position: relative;
}

.btn-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* ==============================
   Utility Classes
   ============================== */

/* Text colors */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }

/* Font weight */
.font-semibold { font-weight: 600 !important; }

/* Colored left borders */
.border-left-success { border-left: 4px solid var(--success); }
.border-left-warning { border-left: 4px solid var(--warning); }
.border-left-danger { border-left: 4px solid var(--danger); }
.border-left-primary { border-left: 4px solid var(--primary); }

/* Spacing */
.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: 8px !important; }
.mb-md { margin-bottom: 16px !important; }
.mb-lg { margin-bottom: 24px !important; }
.mt-sm { margin-top: 8px !important; }
.mt-md { margin-top: 16px !important; }

/* Display */
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.gap-sm { gap: 8px !important; }
.gap-md { gap: 16px !important; }

/* Layout */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.max-w-500 { max-width: 500px; }
.max-w-600 { max-width: 600px; }

/* Forms */
.check-form {
    max-width: 500px;
}

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

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

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    border-color: var(--primary);
}

.radio-option input[type="radio"] {
    margin-top: 4px;
    width: 18px;
    height: 18px;
}

.radio-option input[type="radio"]:checked + .radio-label {
    color: var(--primary);
}

.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: #eff6ff;
}

.radio-label {
    display: flex;
    flex-direction: column;
}

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

/* Result Cards */
.result-card {
    margin-top: 32px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.result-safe {
    border: 2px solid var(--success);
}

.result-warning {
    border: 2px solid var(--danger);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.result-safe .result-header {
    background: #dcfce7;
}

.result-warning .result-header {
    background: #fee2e2;
}

.result-icon {
    font-size: 2.5rem;
}

.result-header h2 {
    font-size: 1.5rem;
}

.result-body {
    padding: 24px;
    background: var(--surface);
}

.result-message {
    font-size: 1.1rem;
}

.result-message.success {
    color: var(--success);
}

.warning-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.warning-item.context {
    background: #eff6ff;
}

.warning-item.risk {
    background: #fef2f2;
}

.warning-icon {
    font-size: 1.25rem;
}

.warning-details p {
    margin-bottom: 4px;
}

.warning-message {
    font-weight: 600;
    font-size: 1.05rem;
}

.warning-date {
    color: var(--text-muted);
}

.warning-trades {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.loss-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fef3c7;
    border-radius: var(--radius);
    margin-top: 16px;
    font-weight: 500;
}

.loss-icon {
    font-size: 1.25rem;
}

.alternatives-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #e0e7ff;
    border-radius: var(--radius);
    margin-top: 16px;
}

.info-note {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius);
    margin-top: 16px;
    color: var(--text-muted);
}

/* Auth Page */
.auth-status {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.auth-connected {
    background: #dcfce7;
}

.auth-disconnected {
    background: #fef2f2;
}

.status-icon {
    font-size: 3rem;
}

.status-details h3 {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    gap: 12px;
}

.info-label {
    color: var(--text-muted);
    min-width: 200px;
}

.info-value {
    font-weight: 500;
}

.text-warning {
    color: var(--warning);
}

.auth-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.auth-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fef3c7;
    border-radius: var(--radius);
    margin-top: 24px;
}

.info-section {
    margin-bottom: 24px;
}

.info-section h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text);
}

.auth-steps {
    padding-left: 24px;
}

.auth-steps li {
    margin-bottom: 8px;
    color: var(--text-muted);
}

.token-info {
    list-style: none;
}

.token-info li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.token-info li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary);
}

.callback-url {
    display: block;
    padding: 12px 16px;
    background: var(--background);
    border-radius: var(--radius);
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9rem;
    overflow-x: auto;
}

.help-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 24px;
}

.flash-message {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
}

.flash-warning {
    background: #fef3c7;
    color: #92400e;
}

.flash-info {
    background: #e0e7ff;
    color: #4338ca;
}

/* Error Banner */
.error-banner {
    padding: 16px 20px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive */
/* Table footer totals */
.data-table tfoot td {
    padding: 16px;
    background: var(--background);
    border-top: 2px solid var(--border);
}

/* Section headers inside cards */
.card-body h3 {
    color: var(--text);
    font-weight: 600;
}

/* Synthetic lot badge */
.badge-synth {
    background: #fef3c7;
    color: #92400e;
}

/* Warning button */
.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
}

/* CSV import badge */
.badge-csv {
    background: #dbeafe;
    color: #1e40af;
}

/* File upload area */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    background: var(--background);
    transition: border-color 0.2s;
}

.file-upload-area:hover {
    border-color: var(--primary);
}

.file-upload-label {
    display: block;
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
}

.file-upload-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Select dropdown styling */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Severity badges */
.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #e0f2fe;
    color: #075985;
}

/* Critical alert banner */
.alert {
    padding: 16px 24px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.alert-critical {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.alert-critical strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.alert-critical p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    /* Show hamburger, hide nav links by default */
    .menu-toggle {
        display: flex;
    }

    .nav-container {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 0;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 4px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
        margin-top: 12px;
    }

    .nav-links.nav-open {
        display: flex;
    }

    .nav-link {
        width: 100%;
        text-align: center;
        padding: 10px 16px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }

    .radio-group {
        flex-direction: column;
    }

    .info-row {
        flex-direction: column;
        gap: 4px;
    }

    .info-label {
        min-width: auto;
    }

    .auth-status {
        flex-direction: column;
        text-align: center;
    }

    .auth-actions {
        justify-content: center;
    }

    .info-bar {
        flex-direction: column;
        gap: 12px;
    }

    .info-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .grid-2col {
        grid-template-columns: 1fr;
    }
}

/* ==============================
   Print Stylesheet
   ============================== */
@media print {
    .navbar,
    .footer,
    .info-actions,
    .btn,
    .flash-messages,
    .menu-toggle {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .main-content {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

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

    .stat-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .stats-row {
        grid-template-columns: repeat(4, 1fr);
    }

    .text-success { color: #16a34a !important; }
    .text-danger { color: #dc2626 !important; }

    .data-table {
        font-size: 0.8rem;
    }

    .table-container::after {
        display: none;
    }

    .page-header {
        margin-bottom: 16px;
    }

    .page-header .subtitle {
        display: none;
    }

    .info-bar {
        border: none;
        padding: 8px 0;
    }
}
