/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.25rem;
    color: #666;
}

/* Search section */
.search-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 600px) {
    .search-section {
        flex-direction: row;
        align-items: flex-end;
    }
}

.input-group {
    flex: 1;
    position: relative;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 0.25rem;
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.search-button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background-color: #f59e0b;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.search-button:hover {
    background-color: #d97706;
}

.search-button:disabled {
    background-color: #fcd34d;
    cursor: not-allowed;
}

/* Autocomplete */
.autocomplete-items {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background-color: white;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.autocomplete-items.active {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: #fef3c7;
}

.autocomplete-item .county-name {
    font-weight: 500;
}

/* Examples */
.examples {
    text-align: center;
    margin-bottom: 2rem;
    color: #666;
    font-size: 0.9rem;
}

.example-btn {
    background: none;
    border: none;
    color: #d97706;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
    padding: 0.25rem;
    margin: 0 0.25rem;
}

.example-btn:hover {
    color: #b45309;
}

/* Results */
.results {
    margin-top: 2rem;
}

.results.hidden {
    display: none;
}

/* Hero section */
.hero-section {
    text-align: center;
    background-color: white;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.county-title {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.hero-stat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.swing-value {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.swing-value.positive {
    color: #d97706;
}

.swing-value.negative {
    color: #6366f1;
}

.swing-value.neutral {
    color: #6b7280;
}

/* Classification badge */
.classification-badge {
    display: inline-block;
    padding: 0.375rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-magnet {
    background-color: #fef3c7;
    color: #92400e;
    border: 2px solid #f59e0b;
}

.badge-bedroom {
    background-color: #e0e7ff;
    color: #3730a3;
    border: 2px solid #818cf8;
}

.badge-self-contained {
    background-color: #f3f4f6;
    color: #374151;
    border: 2px solid #9ca3af;
}

/* Percentile bar */
.percentile-display {
    max-width: 400px;
    margin: 0 auto;
}

.percentile-bar {
    display: block;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.percentile-fill {
    display: block;
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease-out;
    background: linear-gradient(90deg, #818cf8, #9ca3af 50%, #f59e0b);
}

.percentile-text {
    display: block;
    font-size: 0.85rem;
    color: #666;
    text-align: center;
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-card {
    background-color: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a1a;
}

.stat-sublabel {
    display: block;
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

/* Chart panel */
.chart-panel {
    background-color: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.chart-panel h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-container {
    position: relative;
    height: 120px;
    margin-bottom: 0.75rem;
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #666;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-dot.out-commuters {
    background-color: #818cf8;
}

.legend-dot.internal-workers {
    background-color: #d1d5db;
}

.legend-dot.in-commuters {
    background-color: #f59e0b;
}

/* Flow tables */
.flow-tables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
    .flow-tables {
        grid-template-columns: 1fr 1fr;
    }
}

.flow-table {
    background-color: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.flow-table h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.flow-subtitle {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 1rem;
}

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

.flow-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0;
    border-bottom: 2px solid #e5e7eb;
}

.flow-table th:last-child {
    text-align: right;
}

.flow-table td {
    padding: 0.625rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.flow-table td:first-child {
    color: #999;
    width: 2rem;
}

.flow-table td:last-child {
    text-align: right;
    color: #666;
}

.flow-table tr:last-child td {
    border-bottom: none;
}

.county-link {
    color: #d97706;
    cursor: pointer;
    text-decoration: none;
}

.county-link:hover {
    text-decoration: underline;
    color: #b45309;
}

/* Insight callout */
.insight-callout {
    background-color: white;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #f59e0b;
    margin-bottom: 1rem;
}

.insight-callout.insight-magnet {
    border-left-color: #f59e0b;
}

.insight-callout.insight-bedroom {
    border-left-color: #818cf8;
}

.insight-callout.insight-balanced {
    border-left-color: #9ca3af;
}

.insight-callout .insight-text {
    font-size: 1rem;
    color: #333;
    line-height: 1.5;
}

/* Small county notice */
.small-county-notice {
    background-color: #fffbeb;
    color: #92400e;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.small-county-notice.hidden {
    display: none;
}

/* Error */
.error {
    background-color: #fef2f2;
    color: #dc2626;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    text-align: center;
}

.error.hidden {
    display: none;
}

/* Footer */
footer {
    margin-top: 4rem;
    text-align: center;
    color: #888;
    font-size: 0.875rem;
}

footer a {
    color: #d97706;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

footer p {
    margin-bottom: 0.5rem;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}
