/* EsperantAI — estilos de index.html (la UI principal).
   Extraído de index.html para TASK-105 CSP hardening Fase 1.
   Sin cambios funcionales. */

/* ─── TASK-105 fase 2: clases que reemplazan los style="..." inline ─────── */

.profile-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.profile-label {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.profile-select {
    padding: 6px 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    min-width: 120px;
}

.profile-btn {
    padding: 4px 12px;
    font-size: 11px;
}

.profile-btn-danger {
    padding: 4px 12px;
    font-size: 11px;
    color: var(--danger);
}

.panel-mt {
    margin-top: 16px;
}

.muted-small {
    font-size: 12px;
    color: var(--text-muted);
}

.legal-list {
    font-size: 12px;
    line-height: 1.8;
}

.hidden {
    display: none;
}

.history-area {
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: 11px;
}

.history-empty {
    color: var(--text-muted);
}

.row-mt {
    margin-top: 8px;
}

.btn-small {
    font-size: 11px;
}

.slider-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.threshold-slider {
    flex: 1;
    accent-color: var(--brand-1);
}

.threshold-value {
    font-family: Consolas, monospace;
    color: var(--brand-1);
    min-width: 50px;
    text-align: right;
}

.history-empty-note {
    padding: 8px;
    color: var(--text-muted);
}

.history-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.history-status {
    font-weight: 700;
}

.history-status.ok {
    color: #56d364;
}

.history-status.fail {
    color: #ff7b72;
}

.history-status.pending,
.history-time,
.history-source {
    color: var(--text-muted);
}

.history-trigger {
    color: var(--brand-1);
}

.history-scene {
    color: var(--brand-2);
}

.history-source {
    font-size: 10px;
}

/* ──────────────────────────────────────────────────────────────────────── */

:root {
            --bg: #0d1117;
            --panel: #161b22;
            --panel-2: #1c2128;
            --text: #c9d1d9;
            /* Z-205 fix 1.4.3: --text-muted aumentado de #8b949e (4.0:1) a #a0adb8 (5.0:1)
               para cumplir WCAG AA mínimo de 4.5:1 sobre --bg #0d1117 */
            --text-muted: #a0adb8;
            /* Z-205 fix 1.4.11: --border aumentado de #30363d (1.9:1) a #444c56 (2.8:1)
               para mejorar contraste de borders de componentes (target AA: 3:1) */
            --border: #444c56;
            --brand-1: #58a6ff;
            --brand-2: #bc8cff;
            --brand-3: #ff7b72;
            --success: #238636;
            --warning: #d29922;
            --danger: #da3633;
            --brand-gradient: linear-gradient(135deg, #58a6ff 0%, #bc8cff 50%, #ff7b72 100%);
        }

        /* Z-205 fix 2.4.7: focus visible para teclado / lectores de pantalla.
           Sin esto, la navegación por TAB es invisible en buttons/inputs/links/selects. */
        :focus-visible {
            outline: 2px solid var(--brand-1);
            outline-offset: 2px;
            border-radius: 4px;
        }
        /* Solo remover el outline default cuando NO es focus-visible (mouse click).
           Permite que mouse clicks no muestren outline pero TAB sí. */
        :focus:not(:focus-visible) {
            outline: none;
        }

        /* Z-205 fix 2.4.1: skip link para teclado. Visualmente oculto hasta foco. */
        .skip-link {
            position: absolute;
            top: -100px;
            left: 8px;
            padding: 10px 16px;
            background: var(--brand-1);
            color: var(--bg);
            border-radius: 6px;
            font-weight: 700;
            text-decoration: none;
            z-index: 100000;
            transition: top 0.2s;
        }
        .skip-link:focus,
        .skip-link:focus-visible {
            top: 8px;
            outline: 2px solid var(--brand-2);
            outline-offset: 2px;
        }

        /* Z-205 fix: .brand-name ahora es <h1> — resetear estilos default del h1
           para mantener el look del div original (font-size pequeño + inline) */
        h1.brand-name {
            font-size: 1.2em;
            font-weight: 700;
            margin: 0;
            line-height: 1.2;
            color: var(--text);
        }

        /* Z-205 fix prefers-reduced-motion: respetar preferencia OS */
        @media (prefers-reduced-motion: reduce) {
            *,
            *::before,
            *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
                scroll-behavior: auto !important;
            }
            .skip-link { transition: none; }
        }
        * { box-sizing: border-box; }
        body {
            background: var(--bg);
            color: var(--text);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0; padding: 20px;
            display: flex; flex-direction: column; align-items: center;
            min-height: 100vh;
        }
        html[dir="rtl"] body { direction: rtl; }

        /* Header */
        .brand-header {
            display: flex; align-items: center; justify-content: center;
            gap: 16px; margin-bottom: 12px;
        }
        .brand-banner {
            display: block;
            height: auto;
            max-width: 260px;
            width: 100%;
            object-fit: contain;
            filter: drop-shadow(0 0 16px rgba(88, 166, 255, 0.18));
        }
        /* Visually hidden but accessible to screen readers */
        .visually-hidden {
            position: absolute !important;
            width: 1px; height: 1px;
            padding: 0; margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }
        .brand-subtitle {
            font-size: 0.85em; color: var(--text-muted); text-align: center;
            margin-bottom: 16px;
        }

        /* Status bar */
        .status-bar {
            display: flex; gap: 10px; margin-bottom: 16px;
            flex-wrap: wrap; justify-content: center;
        }
        .badge {
            padding: 6px 14px; border-radius: 20px;
            font-weight: 600; font-size: 12px;
            background: var(--border); color: var(--text);
            display: inline-flex; align-items: center; gap: 6px;
        }
        .badge.ok { background: var(--success); color: #fff; }
        .badge.warn { background: var(--warning); color: #0d1117; }
        .badge.err { background: var(--danger); color: #fff; }

        /* Language selector */
        .lang-selector {
            position: absolute; top: 20px; right: 20px;
            background: var(--panel); border: 1px solid var(--border);
            border-radius: 8px; padding: 6px 10px;
            color: var(--text); font-size: 13px; cursor: pointer;
        }
        html[dir="rtl"] .lang-selector { right: auto; left: 20px; }

        /* Dashboard layout */
        .dashboard {
            display: grid;
            grid-template-columns: minmax(480px, 1fr) minmax(400px, 1fr);
            gap: 20px; width: 100%; max-width: 1400px;
        }
        @media (max-width: 1000px) {
            .dashboard { grid-template-columns: 1fr; }
        }
        .panel {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 18px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        }
        .panel h2 {
            margin: 0 0 14px 0; font-size: 1.1em;
            color: var(--brand-1);
            border-bottom: 1px solid var(--border);
            padding-bottom: 8px;
        }

        /* Video panel */
        .video-panel { text-align: center; }
        @media (min-width: 1001px) {
            .video-panel { position: sticky; top: 20px; align-self: start; }
        }
        #video-container {
            position: relative;
            display: inline-block;
            margin: 10px auto;
            border-radius: 12px;
            overflow: hidden;
            background: #000;
            max-width: 100%;
            box-shadow: 0 0 0 2px var(--brand-1), 0 0 20px rgba(88, 166, 255, 0.3);
        }
        #video { display: block; width: 100%; max-width: 640px; height: auto; }
        #overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

        .current-pose {
            margin: 12px 0; padding: 14px;
            background: var(--panel-2);
            border-radius: 8px;
            font-size: 1.5em; font-weight: 700;
            background: var(--brand-gradient);
            -webkit-background-clip: text; background-clip: text;
            color: transparent;
            min-height: 50px;
            display: flex; align-items: center; justify-content: center;
            flex-direction: column;
        }
        .current-pose-sub {
            font-size: 0.5em; color: var(--text-muted);
            font-weight: 400; margin-top: 4px;
            -webkit-text-fill-color: var(--text-muted);
        }

        .metrics-grid {
            display: grid; grid-template-columns: repeat(3, 1fr);
            gap: 6px; margin-top: 10px;
        }
        .metric {
            background: var(--panel-2);
            border-radius: 6px;
            padding: 8px 10px;
            font-size: 11px;
            text-align: left;
        }
        .metric-label {
            color: var(--text-muted);
            text-transform: uppercase;
            font-size: 9px;
            letter-spacing: 0.5px;
        }
        .metric-value {
            color: var(--brand-1);
            font-family: 'Consolas', monospace;
            font-weight: 700;
            font-size: 14px;
        }

        /* Form controls */
        label {
            display: block;
            margin-top: 12px;
            font-size: 12px;
            color: var(--text-muted);
            font-weight: 500;
        }
        input[type="text"], input[type="password"], select {
            width: 100%; padding: 9px 12px;
            margin-top: 4px;
            border-radius: 6px;
            border: 1px solid var(--border);
            background: var(--bg);
            color: var(--text);
            font-size: 13px;
            outline: none;
            transition: border-color 0.15s;
        }
        input:focus, select:focus { border-color: var(--brand-1); }

        button {
            padding: 10px 18px;
            border-radius: 8px;
            border: none;
            font-weight: 700;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.15s;
        }
        button.primary {
            background: var(--brand-gradient);
            color: #0d1117;
        }
        button.primary:hover { opacity: 0.9; transform: translateY(-1px); }
        button.secondary {
            background: var(--border);
            color: var(--text);
        }
        button.danger {
            background: var(--danger);
            color: #fff;
        }

        .row { display: flex; gap: 8px; margin-top: 12px; }
        .row > * { flex: 1; }

        details {
            margin-top: 12px;
            background: var(--panel-2);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 12px 14px;
        }
        details > summary {
            cursor: pointer;
            font-weight: 600;
            color: var(--brand-1);
            display: flex; align-items: center; gap: 6px;
            user-select: none;
        }
        details > summary::-webkit-details-marker { display: none; }
        details > summary::before { content: '▶'; font-size: 0.7em; transition: transform 0.2s; }
        details[open] > summary::before { transform: rotate(90deg); }

        .hint {
            margin-top: 8px;
            padding: 8px 12px;
            background: rgba(88, 166, 255, 0.05);
            border-left: 3px solid var(--brand-1);
            border-radius: 4px;
            font-size: 11px;
            color: var(--text-muted);
            font-style: italic;
        }

        .footer {
            margin-top: 24px;
            color: var(--text-muted);
            font-size: 11px;
            text-align: center;
        }
        .footer a {
            color: var(--brand-1);
            text-decoration: none;
        }
        .kbd {
            display: inline-block;
            padding: 1px 6px;
            background: var(--border);
            border-radius: 4px;
            font-family: 'Consolas', monospace;
            font-size: 10px;
            border-bottom: 2px solid #444c56;
        }

        /* Trigger UI Builder */
        .tb-banner {
            background: linear-gradient(135deg, rgba(88,166,255,0.08), rgba(188,140,255,0.08));
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 10px 14px;
            margin-bottom: 12px;
        }
        .tb-banner-title { font-size: 13px; font-weight: 700; color: var(--brand-1); margin-bottom: 4px; }
        .tb-banner-text { font-size: 11px; color: var(--text-muted); line-height: 1.5; }
        .tb-universal-marker { color: #56d364; font-weight: 600; }
        .tb-cultural-marker { color: #d29922; font-weight: 600; }
        .tb-small { font-size: 11px; }
        .tb-warning {
            background: rgba(210, 153, 34, 0.1);
            border-left: 3px solid var(--warning);
            border-radius: 4px;
            padding: 10px 12px;
            margin-bottom: 12px;
            font-size: 12px;
        }
        .tb-category {
            margin-top: 8px;
            background: var(--panel-2);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 10px 14px;
        }
        .tb-category > summary {
            display: flex; align-items: center; gap: 10px;
            cursor: pointer; font-weight: 600; color: var(--brand-1);
            user-select: none;
        }
        .tb-category > summary::-webkit-details-marker { display: none; }
        .tb-category > summary::before { content: '▶'; font-size: 0.7em; transition: transform 0.2s; }
        .tb-category[open] > summary::before { transform: rotate(90deg); }
        .tb-cat-emoji { font-size: 1.1em; }
        .tb-toggle {
            margin-left: auto;
            display: inline-flex; align-items: center; gap: 6px;
            font-size: 11px; color: var(--text-muted); font-weight: 400;
        }
        .tb-toggle input[type="checkbox"] { accent-color: var(--brand-1); cursor: pointer; }
        .tb-category-body { margin-top: 10px; }
        .tb-category-body.tb-disabled { opacity: 0.4; pointer-events: none; }
        .tb-row {
            display: grid;
            grid-template-columns: 180px 1fr;
            gap: 10px;
            align-items: center;
            padding: 4px 0;
        }
        .tb-row-label {
            display: flex; align-items: center; gap: 6px;
            font-size: 12px; color: var(--text);
        }
        .tb-icon { font-size: 1.1em; }
        .tb-label { flex: 1; }
        .tb-scene-select {
            width: 100%; padding: 6px 8px;
            background: var(--bg); color: var(--text);
            border: 1px solid var(--border);
            border-radius: 4px;
            font-size: 12px;
        }
        .tb-scene-select:disabled { opacity: 0.5; cursor: not-allowed; }

        /* Multi-action UI */
        .tb-row-actions {
            display: flex; align-items: center; gap: 6px; flex: 1;
        }
        .tb-action-count {
            font-size: 10px; background: var(--brand-1); color: #0d1117;
            padding: 1px 6px; border-radius: 10px; font-weight: 600;
            white-space: nowrap;
        }
        .tb-action-config-btn {
            padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border);
            background: var(--panel); cursor: pointer; font-size: 12px;
            color: var(--text); transition: all 0.15s;
        }
        .tb-action-config-btn:hover { border-color: var(--brand-1); background: var(--panel-2); }
        .tb-action-config-btn:disabled { opacity: 0.4; cursor: not-allowed; }

        /* Action config modal */
        .action-modal-overlay {
            position: fixed; inset: 0; background: rgba(0,0,0,0.7);
            z-index: 50000; display: flex; align-items: center; justify-content: center;
            backdrop-filter: blur(4px);
        }
        .action-modal {
            background: var(--panel); border: 1px solid var(--border);
            border-radius: 12px; padding: 20px; width: 90%; max-width: 560px;
            max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
        }
        .action-modal h3 {
            margin: 0 0 16px 0; font-size: 1.1em; color: var(--brand-1);
            border-bottom: 1px solid var(--border); padding-bottom: 8px;
        }
        .action-item {
            background: var(--panel-2); border: 1px solid var(--border);
            border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
            display: flex; align-items: center; gap: 10px;
        }
        .action-item-type {
            font-size: 11px; font-weight: 600; color: var(--brand-2);
            background: rgba(188,140,255,0.1); padding: 2px 8px; border-radius: 4px;
        }
        .action-item-params {
            flex: 1; font-size: 11px; color: var(--text-muted); overflow: hidden;
            text-overflow: ellipsis; white-space: nowrap;
        }
        .action-item-delete {
            cursor: pointer; color: var(--danger); font-size: 14px;
            padding: 2px 6px; border: none; background: none;
        }
        .action-item-delete:hover { opacity: 0.7; }

/* ============================================================================
 * Calibration Wizard (TASK-102)
 * Imported from ChatGPT bundle, kept as plain CSS for CSP compliance.
 * ========================================================================== */
body.modal-open { overflow: hidden; }
.modal-overlay[hidden] { display: none !important; }
.modal-overlay {
    position: fixed; inset: 0; z-index: 99999;
    display: grid; place-items: center; padding: 20px;
}
.cw-backdrop {
    position: absolute; inset: 0;
    background: rgba(6, 10, 18, 0.82);
    backdrop-filter: blur(10px);
}
.cw-modal {
    position: relative; z-index: 1; width: min(860px, 100%);
    background: linear-gradient(180deg, rgba(22,27,34,0.98), rgba(13,17,23,0.98));
    border: 1px solid var(--border); border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.45);
    padding: 24px;
}
.cw-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.cw-kicker { color: var(--brand-1); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.cw-header h2 { margin: 0; font-size: 1.6em; }
.cw-header p { color: var(--text-muted); margin: 8px 0 0 0; }
.cw-close { background: transparent; color: var(--text-muted); border: 1px solid var(--border); border-radius: 10px; width: 40px; height: 40px; font-size: 24px; cursor: pointer; }
.cw-progress { margin: 18px 0 22px; width: 100%; height: 8px; appearance: none; background: #0d1117; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.cw-progress::-webkit-progress-bar,
.cw-inline-progress::-webkit-progress-bar { background: #0d1117; border-radius: 999px; }
.cw-progress::-webkit-progress-value,
.cw-inline-progress::-webkit-progress-value { background: var(--brand-gradient); border-radius: 999px; }
.cw-progress::-moz-progress-bar,
.cw-inline-progress::-moz-progress-bar { background: var(--brand-gradient); border-radius: 999px; }
.cw-step-body { min-height: 280px; }
.cw-intro-grid, .cw-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cw-card { background: rgba(28, 33, 40, 0.85); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.cw-card.tone { background: rgba(88, 166, 255, 0.08); }
.cw-card h3 { margin-top: 0; }
.cw-card ul { margin: 10px 0 0 18px; color: var(--text-muted); line-height: 1.6; }
.cw-card p { color: var(--text-muted); line-height: 1.6; }
.cw-actions-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.cw-capture-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: #0d1117; border: 1px solid var(--border); color: var(--brand-1); font-size: 12px; font-weight: 700; }
.cw-inline-progress { width: 100%; height: 8px; appearance: none; background: #0d1117; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); margin-top: 12px; }
.cw-status { margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--border); color: var(--text-muted); }
.cw-status.ok { color: #d2f7dc; border-style: solid; border-color: rgba(35, 134, 54, 0.65); background: rgba(35, 134, 54, 0.12); }
.cw-footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 22px; }
.cw-footer-right { display: flex; gap: 10px; align-items: center; }
.cw-metric-list { list-style: none; padding: 0; margin: 12px 0 0 0; }
.cw-metric-list li { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(48, 54, 61, 0.6); }
.cw-metric-list li:last-child { border-bottom: none; }
@media (max-width: 760px) {
    .cw-intro-grid, .cw-summary-grid { grid-template-columns: 1fr; }
    .cw-footer { flex-direction: column-reverse; align-items: stretch; }
    .cw-footer-right { width: 100%; justify-content: stretch; }
    .cw-footer-right > * { flex: 1; }
}

/* ============================================================================
 * Combo Triggers UI (Pro+ feature)
 * Panel para configurar evento de plataforma + gesto físico → acciones.
 * ========================================================================== */
.combo-hint {
    color: var(--text-muted); font-size: 12px; margin-bottom: 12px;
    line-height: 1.5;
}
.combo-list {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 12px;
}
.combo-empty {
    color: var(--text-muted); font-size: 13px;
    padding: 16px; border: 1px dashed var(--border);
    border-radius: 8px; text-align: center;
}
.combo-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto auto auto;
    gap: 8px; align-items: center;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.combo-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-muted);
    cursor: pointer; white-space: nowrap;
}
.combo-toggle input { cursor: pointer; }
.combo-event-select, .combo-gesture-select {
    width: 100%; min-width: 0;
}
.combo-arrow {
    color: var(--brand-1); font-weight: bold;
    user-select: none;
}
.combo-action-summary {
    font-size: 11px; color: var(--text-muted);
    white-space: nowrap; padding: 2px 8px;
    background: rgba(88,166,255,0.08);
    border-radius: 12px;
}
.combo-actions-btn {
    padding: 4px 10px; font-size: 12px;
}
.combo-remove-btn {
    padding: 2px 8px; font-size: 14px;
    background: none; border: 1px solid var(--danger);
    color: var(--danger);
}
.combo-remove-btn:hover {
    background: var(--danger); color: white;
}
.combo-toolbar {
    display: flex; justify-content: flex-end;
}
.combo-locked {
    text-align: center; padding: 24px 16px;
    background: rgba(88,166,255,0.05);
    border: 1px dashed var(--border);
    border-radius: 12px;
}
.combo-locked h3 { margin-top: 0; color: var(--brand-1); }
.combo-locked p { color: var(--text-muted); margin: 8px 0; }
@media (max-width: 760px) {
    .combo-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .combo-arrow { display: none; }
}
