/* ============ CSS Variables ============ */
:root {
    /* Light theme */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

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

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

/* ============ Header ============ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
:root .icon-sun { display: none; }
:root .icon-moon { display: inline; }

/* ============ Stats Bar ============ */
.stats-bar {
    display: flex;
    gap: 20px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============ Search Section ============ */
.search-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    overflow: hidden;
}

.search-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--accent-color);
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--accent-color);
}

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

.search-panel {
    display: none;
    padding: 24px;
}

.search-panel.active {
    display: block;
}

/* ============ Form Elements ============ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

input[type="text"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.threshold-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

/* ============ Buttons ============ */
.btn-search {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--accent-color);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-search:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-search:active {
    transform: translateY(0);
}

.btn-search:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ============ Results Section ============ */
.results-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.results-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.results-table-container {
    overflow-x: auto;
}

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

.results-table th,
.results-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.results-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    font-weight: 600;
}

.results-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.results-table td {
    font-size: 0.9rem;
}

/* Score badges */
.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.score-high {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.score-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.score-low {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-color);
}

/* Source badges */
.source-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.source-un {
    background: #dbeafe;
    color: #1e40af;
}

.source-eu {
    background: #fef3c7;
    color: #92400e;
}

[data-theme="dark"] .source-un {
    background: #1e3a5f;
    color: #93c5fd;
}

[data-theme="dark"] .source-eu {
    background: #422006;
    color: #fcd34d;
}

/* Type badge */
.type-badge {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* View button */
.btn-view {
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--accent-color);
    background: transparent;
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-view:hover {
    background: var(--accent-color);
    color: white;
}

/* ============ Batch Results ============ */
.batch-summary {
    padding: 20px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.batch-summary h3 {
    margin-bottom: 12px;
}

.batch-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.batch-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.batch-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.batch-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.batch-results-list {
    padding: 16px 24px;
}

.batch-item {
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
}

.batch-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.batch-item-name {
    font-weight: 600;
}

.batch-item-status {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.batch-item-status.has-matches {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.batch-item-status.no-matches {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-color);
}

.batch-item-matches {
    margin-top: 12px;
    padding-left: 16px;
    border-left: 2px solid var(--border-color);
}

.batch-match {
    padding: 8px 0;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.batch-match:last-child {
    border-bottom: none;
}

/* ============ Modal ============ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.detail-grid {
    display: grid;
    gap: 16px;
}

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

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-word;
}

.detail-value:empty::after {
    content: '-';
    color: var(--text-muted);
}

/* ============ Footer ============ */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.disclaimer {
    margin-top: 8px;
    font-size: 0.75rem;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .stats-bar {
        justify-content: center;
    }

    .search-tabs {
        flex-direction: column;
    }

    .tab-btn {
        padding: 12px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-table th,
    .results-table td {
        padding: 8px 12px;
    }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

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

.empty-state-text {
    font-size: 1rem;
}
