/* Paycheck Passport – Main Stylesheet */
/* Mobile-first, system dark mode support */

:root {
    /* Colors – Light mode */
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border: #e5e5e5;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --badge-detailed: #dcfce7;
    --badge-detailed-text: #166534;
    --badge-rough: #fef3c7;
    --badge-rough-text: #92400e;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;

    /* Borders */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --bg-primary: #0a0a0a;
        --bg-secondary: #141414;
        --bg-tertiary: #1f1f1f;
        --text-primary: #fafafa;
        --text-secondary: #a3a3a3;
        --text-muted: #737373;
        --border: #2a2a2a;
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --badge-detailed: #064e3b;
        --badge-detailed-text: #6ee7b7;
        --badge-rough: #451a03;
        --badge-rough-text: #fcd34d;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    }
}

[data-theme='dark'] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1f1f1f;
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --border: #2a2a2a;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --badge-detailed: #064e3b;
    --badge-detailed-text: #6ee7b7;
    --badge-rough: #451a03;
    --badge-rough-text: #fcd34d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-lg) var(--space-md);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.logo {
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin-top: var(--space-xs);
}

.theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--text-base);
    transition:
        border-color 0.2s,
        color 0.2s;
}

.theme-toggle:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Main */
.main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
}

/* Input Section */
.input-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.salary-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.form-group label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.input-with-currency {
    display: flex;
    gap: var(--space-sm);
}

.input-with-currency input {
    flex: 1;
    min-width: 0;
}

.input-with-currency select {
    width: 80px;
}

input,
select {
    font-family: inherit;
    font-size: var(--text-base);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type='number'] {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
}

.country-selectors {
    align-items: flex-start;
}

.arrow {
    color: var(--text-muted);
    font-size: var(--text-xl);
    align-self: center;
    margin-top: var(--space-lg);
}

.compare-countries {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.compare-countries select {
    flex: 1;
    min-width: 120px;
}

.region-selectors {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

.region-selectors .form-group {
    flex: 1;
    min-width: 150px;
}

.hidden {
    display: none !important;
}

/* Results Section */
.results-section {
    margin-top: var(--space-xl);
}

.results-grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: 1fr;
}

/* Result Card */
.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.result-card.from-country {
    border-left: 4px solid var(--accent);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.country-name {
    font-size: var(--text-lg);
    font-weight: 600;
}

.country-flag {
    font-size: var(--text-xl);
    margin-right: var(--space-xs);
}

.confidence-badge {
    font-size: var(--text-xs);
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.confidence-badge.detailed {
    background: var(--badge-detailed);
    color: var(--badge-detailed-text);
}

.confidence-badge.rough {
    background: var(--badge-rough);
    color: var(--badge-rough-text);
}

.take-home {
    margin-bottom: var(--space-md);
}

.take-home-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.take-home-amount {
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.take-home-monthly {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.effective-rate {
    display: inline-block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

/* Breakdown Details */
.breakdown-toggle {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--accent);
    font-size: var(--text-sm);
}

.breakdown-toggle:hover {
    text-decoration: underline;
}

.breakdown-content {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-xs) 0;
    font-size: var(--text-sm);
}

.breakdown-row.total {
    font-weight: 600;
    border-top: 1px solid var(--border);
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
}

.breakdown-label {
    color: var(--text-secondary);
}

.breakdown-value {
    font-family: var(--font-mono);
}

.breakdown-value.negative {
    color: #dc2626;
}

.result-meta {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.result-meta a {
    color: var(--accent);
    text-decoration: none;
}

.result-meta a:hover {
    text-decoration: underline;
}

/* Comparison Strip */
.comparison-strip {
    margin-top: var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.comparison-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.comparison-bar:last-child {
    margin-bottom: 0;
}

.comparison-label {
    width: 80px;
    font-size: var(--text-sm);
    font-weight: 500;
    flex-shrink: 0;
}

.comparison-track {
    flex: 1;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.comparison-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
}

.comparison-fill.from {
    background: var(--text-muted);
}

.comparison-value {
    width: 100px;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-align: right;
    flex-shrink: 0;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: var(--space-lg) var(--space-md);
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.disclaimer {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.meta a {
    color: var(--accent);
    text-decoration: none;
}

.meta a:hover {
    text-decoration: underline;
}

/* Responsive – Tablet and up */
@media (min-width: 640px) {
    .form-row {
        flex-direction: row;
        align-items: flex-end;
    }

    .salary-group {
        flex: 1;
        max-width: 300px;
    }

    .country-selectors {
        flex-wrap: wrap;
    }

    .country-selectors .form-group:first-child {
        flex: 0 0 auto;
    }

    .compare-group {
        flex: 1;
    }

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

/* Desktop */
@media (min-width: 1024px) {
    .header {
        padding: var(--space-xl) var(--space-lg);
    }

    .main {
        padding: var(--space-xl) var(--space-lg);
    }

    .results-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }

    .take-home-amount {
        font-size: var(--text-4xl);
    }
}

/* Utilities */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
