/* Virginia Business Scraper - Shared Styles */

:root,
[data-theme="dark"] {
    --bg: #0f1117;
    --bg-elevated: #161922;
    --surface: #1c2030;
    --surface-hover: #252a3a;
    --border: #2a3142;
    --border-light: #353d52;
    --text: #e8eaed;
    --text-muted: #9aa0b4;
    --text-subtle: #6b7289;
    --accent: #4da3ff;
    --accent-hover: #3b8fe8;
    --accent-muted: rgba(77, 163, 255, 0.15);
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
    --input-bg: #12151f;
    --table-header: #141824;
    --chip-bg: #252a3a;
    --rating: #fbbf24;
    --link: #4da3ff;
    --status-new-bg: rgba(154, 160, 180, 0.15);
    --status-new-text: #9aa0b4;
    --status-contacted-bg: rgba(77, 163, 255, 0.15);
    --status-contacted-text: #4da3ff;
    --status-qualified-bg: rgba(52, 211, 153, 0.15);
    --status-qualified-text: #34d399;
    --status-declined-bg: rgba(248, 113, 113, 0.15);
    --status-declined-text: #f87171;
}

[data-theme="light"] {
    --bg: #f5f6fa;
    --bg-elevated: #eef0f5;
    --surface: #ffffff;
    --surface-hover: #f8f9fb;
    --border: #e1e8ed;
    --border-light: #ecf0f1;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --text-subtle: #95a5a6;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --accent-muted: rgba(52, 152, 219, 0.12);
    --success: #27ae60;
    --success-bg: #d5f5e3;
    --warning: #f39c12;
    --warning-bg: #fef3cd;
    --danger: #e74c3c;
    --danger-bg: #fadbd8;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --input-bg: #ffffff;
    --table-header: #f8f9fa;
    --chip-bg: #ecf0f1;
    --rating: #f39c12;
    --link: #3498db;
    --status-new-bg: #ecf0f1;
    --status-new-text: #7f8c8d;
    --status-contacted-bg: #d5e8f7;
    --status-contacted-text: #2980b9;
    --status-qualified-bg: #d5f5e3;
    --status-qualified-text: #27ae60;
    --status-declined-bg: #fadbd8;
    --status-declined-text: #e74c3c;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.2s, color 0.2s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.container-narrow {
    max-width: 900px;
}

/* Header */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    margin-bottom: 30px;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header-inner h1 {
    font-size: 24px;
    color: var(--text);
}

.header-inner p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 2px;
}

header .back {
    color: var(--link);
    text-decoration: none;
    font-size: 14px;
}

header .back:hover {
    text-decoration: underline;
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-light);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Filters */
.filters-panel {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}

.filters-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-count {
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.filter-count.hidden {
    display: none;
}

.filters-toggle-icon {
    color: var(--text-muted);
    transition: transform 0.2s;
}

.filters-panel.collapsed .filters-toggle-icon {
    transform: rotate(-90deg);
}

.filters-body {
    padding: 20px;
}

.filters-panel.collapsed .filters-body {
    display: none;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 15px;
}

.filters-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    flex: 1;
    min-width: 160px;
}

.filter-group.filter-group-sm {
    flex: 0 1 120px;
    min-width: 100px;
}

.filter-group.filter-group-lg {
    flex: 2;
    min-width: 240px;
}

.filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 5px;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 16px;
}

.active-filters:empty {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--chip-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.filter-chip button {
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.filter-chip button:hover {
    color: var(--danger);
}

.results-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    opacity: 0.9;
}

.btn-warning {
    background: var(--warning);
    color: #1a1a1a;
}

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

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

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

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

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

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-card h3 {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

/* Cards grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.business-card {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 20px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.business-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.business-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text);
}

.business-card .meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.business-card .meta span {
    display: inline-block;
    margin-right: 12px;
}

.business-card .city-tag {
    background: var(--chip-bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.business-card .rating {
    color: var(--rating);
}

.business-card .address {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.business-card .phone {
    font-size: 13px;
    color: var(--link);
    margin-bottom: 12px;
}

.business-card .status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-new { background: var(--status-new-bg); color: var(--status-new-text); }
.status-contacted { background: var(--status-contacted-bg); color: var(--status-contacted-text); }
.status-qualified { background: var(--status-qualified-bg); color: var(--status-qualified-text); }
.status-declined { background: var(--status-declined-bg); color: var(--status-declined-text); }

.business-card .actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 20px;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 14px;
    color: var(--text-muted);
}

/* Sections */
.section {
    margin-bottom: 30px;
}

.section h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text);
}

/* Tables */
.jobs-table {
    width: 100%;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-collapse: collapse;
    overflow: hidden;
}

.jobs-table th,
.jobs-table td {
    padding: 12px 15px;
    text-align: left;
    font-size: 13px;
}

.jobs-table th {
    background: var(--table-header);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.03em;
}

.jobs-table tr {
    border-bottom: 1px solid var(--border);
}

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

.jobs-table td {
    color: var(--text);
}

.jobs-table .job-status-running { color: var(--warning); }
.jobs-table .job-status-done { color: var(--success); }
.jobs-table .job-status-failed { color: var(--danger); }

/* Detail page */
.card {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 30px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 16px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.detail-row {
    display: flex;
    margin-bottom: 15px;
}

.detail-label {
    width: 150px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
}

.detail-value {
    flex: 1;
    font-size: 14px;
}

.detail-value a {
    color: var(--link);
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
}

.map-container {
    width: 100%;
    height: 400px;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;
    border: 1px solid var(--border);
}

.map-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

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

/* Alerts & states */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.error-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.error-state h2 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--danger);
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-group {
        min-width: 100%;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

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

    .detail-label {
        width: auto;
    }
}
