/* =============================================
   Publisearch Encuesta WebUI — Neon Dark Theme
   ============================================= */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-sidebar: #0f1320;
    --bg-topbar: #0d1117;
    --bg-input: #1e2536;
    --border-color: #1e293b;
    --border-glow: #00d4ff22;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-cyan: #00d4ff;
    --accent-green: #00ff88;
    --accent-red: #ff3b5c;
    --accent-yellow: #ffd000;
    --accent-purple: #a855f7;
    --accent-orange: #ff8c00;
    --neon-glow: 0 0 10px rgba(0, 212, 255, 0.15);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 0 15px rgba(0,212,255,0.04);
    --scrollbar-track: #111827;
    --scrollbar-thumb: #334155;
    --table-hover: #1e293b;
    --positive: #00ff88;
    --negative: #ff3b5c;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #f8fafc;
    --bg-topbar: #ffffff;
    --bg-input: #f1f5f9;
    --border-color: #e2e8f0;
    --border-glow: transparent;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-cyan: #0891b2;
    --accent-green: #059669;
    --accent-red: #dc2626;
    --accent-yellow: #d97706;
    --accent-purple: #7c3aed;
    --accent-orange: #ea580c;
    --neon-glow: none;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --scrollbar-track: #f1f5f9;
    --scrollbar-thumb: #cbd5e1;
    --table-hover: #f8fafc;
    --positive: #059669;
    --negative: #dc2626;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }

/* LAYOUT */
.app-layout { display: flex; flex-direction: column; height: 100vh; }

/* TOP BAR */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 76px;
    padding: 0 20px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--neon-glow);
    z-index: 100;
    flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo { height: 64px; width: auto; }
.topbar-brand {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-cyan);
    letter-spacing: 0.5px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px; height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}
.theme-toggle:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }

.user-btn {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}
.user-btn:hover { border-color: var(--accent-cyan); }
.user-btn .user-icon {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: #fff; font-weight: 600;
}

/* MAIN AREA */
.main-area { display: flex; flex: 1; overflow: hidden; }

/* SIDEBAR */
.sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; flex-shrink: 0;
    overflow-y: auto;
    padding: 12px 0;
}
.sidebar-section { padding: 0 12px; margin-bottom: 8px; }
.sidebar-section-title {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 8px 12px 6px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: all 0.15s; cursor: pointer;
}
.sidebar-link:hover { background: var(--bg-card); color: var(--text-primary); }
.sidebar-link.active {
    background: rgba(0, 212, 255, 0.08);
    color: var(--accent-cyan);
    box-shadow: inset 3px 0 0 var(--accent-cyan);
}
.sidebar-link .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

/* CONTENT */
.content-area {
    flex: 1; overflow-y: auto;
    padding: 24px;
    background: var(--bg-primary);
}

/* PAGE HEADER */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* CARDS */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px; padding: 20px;
    box-shadow: var(--card-shadow);
    transition: all 0.2s;
}
.stat-card:hover { border-color: var(--border-glow); transform: translateY(-1px); }
.stat-card .card-label {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); margin-bottom: 8px;
}
.stat-card .card-value {
    font-size: 28px; font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.stat-card .card-change {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600; margin-top: 6px;
    padding: 2px 8px; border-radius: 4px;
}
.stat-card .card-change.positive { color: var(--positive); background: rgba(0,255,136,0.08); }
.stat-card .card-change.negative { color: var(--negative); background: rgba(255,59,92,0.08); }
.stat-card .card-icon { float: right; font-size: 22px; opacity: 0.5; margin-top: -4px; }

/* CHARTS */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px; margin-bottom: 24px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px; padding: 20px;
    box-shadow: var(--card-shadow);
}
.chart-card .chart-title {
    font-size: 14px; font-weight: 600;
    margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.chart-card .chart-title .badge {
    font-size: 11px; font-weight: 500;
    padding: 3px 10px; border-radius: 12px;
    background: rgba(0,212,255,0.1); color: var(--accent-cyan);
}
.chart-container { width: 100%; height: 300px; position: relative; }

/* PIE CHART (custom canvas) */
.pie-chart-wrapper {
    display: flex; align-items: center; justify-content: center; gap: 24px;
    height: 300px;
}
.pie-legend {
    display: flex; flex-direction: column; gap: 8px;
}
.pie-legend-item {
    display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.pie-legend-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.pie-legend-value { color: var(--text-muted); font-size: 12px; margin-left: auto; padding-left: 12px; }

/* TABLES */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden; margin-bottom: 24px;
}
.table-card .table-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.table-card .table-header h3 { font-size: 14px; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    padding: 10px 16px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); text-align: left;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.data-table tbody td {
    padding: 10px 16px; font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--table-hover); }
.data-table .text-positive { color: var(--positive); }
.data-table .text-negative { color: var(--negative); }
.data-table .text-muted { color: var(--text-muted); }
.data-table .mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 12px; }

.status-dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; margin-right: 6px;
}
.status-dot.online { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-dot.warning { background: var(--accent-yellow); box-shadow: 0 0 6px var(--accent-yellow); }
.status-dot.offline { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }

/* FILTER CARD */
.filter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 16px;
}
.filter-card .filter-title {
    font-size: 16px; font-weight: 700;
    margin-bottom: 4px;
}
.filter-card .filter-subtitle {
    font-size: 12px; color: var(--text-muted);
    margin-bottom: 16px;
}
.filter-row {
    display: flex; flex-wrap: wrap; gap: 16px;
    align-items: flex-end;
}
.filter-group {
    display: flex; flex-direction: column; gap: 4px;
}
.filter-group label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
}
.filter-group select,
.filter-group input[type="number"] {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    min-width: 100px;
}
.filter-group select:focus,
.filter-group input[type="number"]:focus {
    border-color: var(--accent-cyan);
}
.filter-group select { cursor: pointer; padding-right: 24px; appearance: auto; }
.filter-group input[type="number"] { width: 90px; }

/* Chip toggles (Sexo, NSE) */
.chip-group {
    display: flex; gap: 4px;
}
.chip-toggle {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.chip-toggle.active {
    background: rgba(0, 212, 255, 0.12);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}
.chip-toggle:hover { border-color: var(--accent-cyan); }
.chip-toggle .chip-x {
    font-size: 10px; margin-left: 2px; opacity: 0.6;
}

/* Execute button */
.btn-execute {
    background: var(--accent-cyan);
    color: #0a0e17;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}
.btn-execute:hover { opacity: 0.85; transform: translateY(-1px); }

/* Export button */
.btn-export {
    background: transparent;
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}
.btn-export:hover { background: rgba(0,255,136,0.08); }

/* Rating data table */
.rating-table-wrap {
    overflow-x: auto;
}
.rating-table {
    width: 100%; border-collapse: collapse;
    white-space: nowrap;
}
.rating-table thead th {
    padding: 8px 10px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.3px;
    color: var(--text-muted); text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: sticky; top: 0; z-index: 1;
}
.rating-table thead th:first-child,
.rating-table thead th:nth-child(2) { text-align: left; }
.rating-table tbody td {
    padding: 7px 10px; font-size: 12px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.rating-table tbody td:nth-child(2) {
    text-align: left; font-family: inherit; font-weight: 500;
}
.rating-table tbody tr:hover { background: var(--table-hover); }
.rating-table tbody tr.checked-row {
    background: rgba(0, 212, 255, 0.05);
}
.rating-table td.avg-col {
    font-weight: 700; color: var(--accent-cyan);
}

/* Checkbox (neon style) */
.neon-check {
    appearance: none;
    width: 18px; height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    transition: all 0.15s;
    flex-shrink: 0;
}
.neon-check:checked {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}
.neon-check:checked::after {
    content: '';
    position: absolute;
    left: 5px; top: 2px;
    width: 4px; height: 8px;
    border: solid #0a0e17;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.neon-check:hover { border-color: var(--accent-cyan); }

/* Chart card full width */
.chart-card-full {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px; padding: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}
.chart-card-full .chart-title {
    font-size: 14px; font-weight: 600;
    margin-bottom: 4px;
}
.chart-card-full .chart-subtitle {
    font-size: 12px; color: var(--text-muted);
    margin-bottom: 16px;
}
.chart-full-container { width: 100%; height: 320px; position: relative; }

/* Color line indicator in table */
.color-line {
    display: inline-block; width: 16px; height: 3px;
    border-radius: 2px; vertical-align: middle;
}

/* AUTH PAGES */
.auth-page {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    overflow: auto;
}
.auth-container {
    display: flex; flex-direction: column; align-items: center;
    width: 100%; max-width: 420px;
    padding: 24px;
}
.auth-logo { margin-bottom: 32px; }
.auth-logo img { height: 80px; width: auto; }

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    box-shadow: var(--card-shadow);
}
.auth-title {
    font-size: 20px; font-weight: 700;
    margin-bottom: 6px;
}
.auth-subtitle {
    font-size: 13px; color: var(--text-muted);
    margin-bottom: 24px; line-height: 1.5;
}
.auth-subtitle strong { color: var(--accent-cyan); }

.auth-field {
    margin-bottom: 16px;
}
.auth-field label {
    display: block;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.auth-field input[type="email"],
.auth-field input[type="number"],
.auth-field select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.auth-field input:focus,
.auth-field select:focus { border-color: var(--accent-cyan); }
.auth-field input::placeholder { color: var(--text-muted); }
.auth-field select { cursor: pointer; appearance: auto; }

/* Code digit inputs */
.code-inputs {
    display: flex; gap: 8px; justify-content: center;
}
.code-digit {
    width: 48px; height: 56px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 24px; font-weight: 700;
    text-align: center;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    outline: none;
    transition: border-color 0.2s;
}
.code-digit:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.auth-error {
    background: rgba(255, 59, 92, 0.1);
    border: 1px solid rgba(255, 59, 92, 0.3);
    color: var(--accent-red);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-btn {
    width: 100%;
    background: var(--accent-cyan);
    color: #0a0e17;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-btn:hover { opacity: 0.85; }
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-top-color: #0a0e17;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@@keyframes spin { to { transform: rotate(360deg); } }

.auth-link-row {
    text-align: center; margin-top: 16px;
}
.auth-link {
    color: var(--accent-cyan); font-size: 13px;
    text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

.auth-footer {
    position: fixed; bottom: 16px; right: 16px;
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .charts-row { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
    .filter-row { flex-direction: column; }
    .code-digit { width: 42px; height: 48px; font-size: 20px; }
}
