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

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --border: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.4);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.15);
    --gradient-1: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
    --gradient-2: linear-gradient(135deg, #0ea5e9, #6366f1);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ====== App Container ====== */
.app {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
}

.badge {
    background: var(--accent-glow);
    color: var(--accent-light);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    letter-spacing: 0.5px;
}

/* ====== Cards ====== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: border-color 0.3s ease;
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.card-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-error {
    border-color: var(--error);
    background: var(--error-glow);
}

/* ====== Source Selection ====== */
.source-options {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

.source-card {
    flex: 1;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
}

.source-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.source-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.divider-or {
    display: flex;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
}

.divider-or span {
    writing-mode: vertical-lr;
}

/* ====== Drop Zone ====== */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 30px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 12px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.drop-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ====== File Info ====== */
.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.file-info span { flex: 1; }

.btn-text-only {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-text-only:hover {
    background: var(--error-glow);
}

/* ====== Radio Groups ====== */
.scrape-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    flex: 1;
}

.radio-group {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.83rem;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.radio-group:hover {
    background: rgba(99, 102, 241, 0.06);
    border-color: var(--border);
}

.radio-group input[type="radio"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* ====== Buttons ====== */
.btn-primary {
    width: 100%;
    padding: 12px 24px;
    background: var(--gradient-1);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: inherit;
    letter-spacing: 0.3px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary.btn-large {
    padding: 14px 24px;
    font-size: 0.95rem;
}

.btn-secondary {
    width: 100%;
    padding: 12px 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-glow);
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent-light);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

/* ====== Progress ====== */
.progress-container {
    margin-bottom: 16px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Loading dots */
.loading-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ====== Data Table ====== */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-left: 8px;
    font-weight: 500;
}

.search-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    color: var(--text-primary);
    font-family: inherit;
    width: 220px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.06);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 420px;
    overflow-y: auto;
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

#data-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

#data-table th {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-light);
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

#data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    color: var(--text-secondary);
    vertical-align: middle;
}

#data-table tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

#data-table tr.selected td {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

#data-table tr {
    cursor: pointer;
    transition: background 0.15s;
}

.th-check {
    width: 40px;
    text-align: center !important;
}

.th-num {
    width: 46px;
}

.td-name {
    font-weight: 500;
    color: var(--text-primary) !important;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-num {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted) !important;
    font-size: 0.76rem;
}

#data-table input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Results table value cells */
.td-val {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Source badges */
.badge-source {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-web {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
}

.badge-vision {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-none {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

/* Apply same styles to results table */
#results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

#results-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

#results-table th {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-light);
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

#results-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    color: var(--text-secondary);
    vertical-align: middle;
}

#results-table tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

/* ====== Stats Grid ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
    text-align: center;
    transition: all 0.3s;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.stat-total .stat-number { color: var(--accent-light); }
.stat-web .stat-number { color: #0ea5e9; }
.stat-vision .stat-number { color: #f59e0b; }
.stat-none .stat-number { color: var(--text-muted); }

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ====== Action Buttons ====== */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ====== Info Section ====== */
.info-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 12px;
}

.info-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px 16px;
    text-align: center;
    transition: all 0.3s;
}

.info-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
}

.info-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.info-card p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ====== Login ====== */
.login-input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    outline: none;
}

.login-input:focus {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 0 20px var(--accent-glow);
}

.login-input::placeholder {
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.login-error {
    background: var(--error-glow);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 500;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
    .app { padding: 24px 16px 40px; }
    .header { flex-direction: column; gap: 12px; text-align: center; }
    .source-options { flex-direction: column; }
    .divider-or span { writing-mode: horizontal-tb; }
    .divider-or { justify-content: center; padding: 8px 0; }
    .info-section { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .card { padding: 20px; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left { flex-wrap: wrap; }
    .search-input { width: 100%; }
}
