/* ============================================
   BuscarCarro Dashboard — Supabase-inspired Design
   ============================================ */

:root {
    --bg-primary: #171717;
    --bg-secondary: #1c1c1c;
    --bg-card: #222222;
    --bg-hover: #2a2a2a;
    --border: #2e2e2e;
    --border-light: #3a3a3a;
    --text-primary: #ededed;
    --text-secondary: #a0a0a0;
    --text-muted: #666;
    --accent: #3ECF8E;
    --accent-dim: rgba(62, 207, 142, 0.15);
    --accent-blue: #3B82F6;
    --accent-blue-dim: rgba(59, 130, 246, 0.15);
    --accent-gold: #F59E0B;
    --danger: #EF4444;
    --radius: 8px;
    --radius-lg: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 0 24px 40px;
}

/* HEADER */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 1.4em; font-weight: 700; }
.badge {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.last-update { font-size: 0.8em; color: var(--text-muted); }
.btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    font-family: var(--font);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* STATUS BAR */
.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--accent-dim);
    border: 1px solid rgba(62, 207, 142, 0.3);
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 0.85em;
    color: var(--accent);
}
.hidden { display: none !important; }
.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* KPI GRID */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    transition: border-color 0.2s;
}
.kpi-card:hover { border-color: var(--border-light); }
.kpi-highlight { border-color: var(--accent); background: rgba(62, 207, 142, 0.05); }
.kpi-value { font-size: 1.8em; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.kpi-highlight .kpi-value { color: var(--accent); }
.kpi-label { font-size: 0.78em; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* CHARTS */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.chart-card h3 { font-size: 0.85em; color: var(--text-secondary); margin-bottom: 16px; font-weight: 500; }

/* FILTERS */
.filters-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}
.filters-bar h2 { font-size: 1em; margin-bottom: 14px; font-weight: 600; }
.filters-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.filter-input, .filter-select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.85em;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}
.filter-input:focus, .filter-select:focus { border-color: var(--accent); }
.filter-input { min-width: 200px; }
.filter-range-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78em;
    color: var(--text-secondary);
}
.filter-range {
    width: 150px;
    accent-color: var(--accent);
}

/* TABLE */
.table-section { margin-bottom: 24px; }
.table-section h2 { font-size: 1em; margin-bottom: 14px; font-weight: 600; }
.table-count { color: var(--text-muted); font-weight: 400; font-size: 0.85em; }
.table-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
thead { background: var(--bg-secondary); }
th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr { transition: background 0.15s; }
tr:hover { background: var(--bg-hover); }

/* Row relevance colors */
tr.relevancia-ouro { background: rgba(62, 207, 142, 0.08); }
tr.relevancia-ouro:hover { background: rgba(62, 207, 142, 0.15); }
tr.relevancia-ouro td:first-child { border-left: 3px solid var(--accent); }

tr.relevancia-prata { background: rgba(59, 130, 246, 0.06); }
tr.relevancia-prata:hover { background: rgba(59, 130, 246, 0.12); }
tr.relevancia-prata td:first-child { border-left: 3px solid var(--accent-blue); }

tr.relevancia-bronze { opacity: 0.7; }
tr.relevancia-bronze:hover { opacity: 1; }

.thumb { width: 60px; height: 42px; object-fit: cover; border-radius: 4px; background: var(--bg-secondary); }
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78em;
    font-weight: 500;
}
.tag-ouro { background: var(--accent-dim); color: var(--accent); }
.tag-prata { background: var(--accent-blue-dim); color: var(--accent-blue); }
.tag-bronze { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.tag-auto { background: var(--accent-dim); color: var(--accent); }
.tag-manual { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.tag-sem-entrada { background: var(--accent-dim); color: var(--accent); }
.tag-com-entrada { background: rgba(239,68,68,0.1); color: var(--danger); }

.link-btn {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85em;
}
.link-btn:hover { text-decoration: underline; }

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

.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.75em;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    body { padding: 0 12px 24px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .filters-row { flex-direction: column; }
    .filter-input { min-width: 100%; }
}
