/* ═══════════════════════════════════════════════════════════════
   RADAR DE BUGS & DIAGNÓSTICO ANTIGRAVITY — STREAMING CAMIRI 2026
   Detector en tiempo real de errores, excepciones, fallos de red y salud.
   Diseño: OLED Glassmorphism + Neon Cyber Luxe (Totalmente responsivo)
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. HUD FLOTANTE (BOTÓN / PILL EN PANTALLA) ── */
.bug-hud-pill {
    position: fixed;
    top: 18px;
    bottom: auto;
    left: 18px;
    z-index: 99970;
    display: none !important;
    align-items: center;
    gap: 8px;
    background: rgba(8, 14, 28, 0.88);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(56, 189, 248, 0.28);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65), 0 0 16px rgba(56, 189, 248, 0.15);
    border-radius: 9999px;
    padding: 6px 14px 6px 10px;
    color: #e2e8f0;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

body.radar-dev-mode .bug-hud-pill,
body[data-radar="true"] .bug-hud-pill {
    display: flex !important;
}

.bug-hud-pill:hover {
    transform: translateY(-2px) scale(1.03);
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75), 0 0 24px rgba(56, 189, 248, 0.3);
}

.bug-hud-pill:active {
    transform: translateY(0) scale(0.98);
}

/* Estado de error: Rojo */
.bug-hud-pill.has-errors {
    border-color: rgba(239, 68, 68, 0.75);
    background: rgba(30, 10, 15, 0.95);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 16px rgba(239, 68, 68, 0.4);
}

/* Estado de advertencia o red: Ámbar */
.bug-hud-pill.has-warnings {
    border-color: rgba(245, 158, 11, 0.65);
    background: rgba(30, 20, 10, 0.92);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 16px rgba(245, 158, 11, 0.35);
}
.bug-hud-pill.has-warnings .bug-hud-badge {
    background: #f59e0b;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.8);
}

.bug-hud-icon {
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bug-hud-label {
    letter-spacing: 0.2px;
}

.bug-hud-badge {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    border-radius: 9999px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
}

.bug-hud-pill.has-errors .bug-hud-badge {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}

/* Modo compacto / minimizado (icono circular) */
.bug-hud-pill.minimized {
    padding: 8px;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    justify-content: center;
}

.bug-hud-pill.minimized .bug-hud-label,
.bug-hud-pill.minimized .bug-hud-badge {
    display: none;
}

/* ── 2. MODAL Y PANEL DE DIAGNÓSTICO ── */
.bug-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: rgba(2, 6, 18, 0.75);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.bug-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.bug-modal-window {
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    background: #060b17;
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.85), 0 0 40px rgba(56, 189, 248, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(12px);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.bug-modal-overlay.active .bug-modal-window {
    transform: scale(1) translateY(0);
}

/* Encabezado */
.bug-modal-header {
    padding: 18px 22px;
    background: rgba(10, 18, 36, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.bug-modal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bug-modal-icon-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(37, 99, 235, 0.3));
    border: 1px solid rgba(56, 189, 248, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.bug-modal-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
    letter-spacing: -0.2px;
}

.bug-modal-subtitle {
    font-size: 12px;
    color: #94a3b8;
    margin: 2px 0 0 0;
}

.bug-modal-close {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.bug-modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* Barra de acciones principales (El botón de reporte para IA es protagonista) */
.bug-modal-actions-bar {
    padding: 14px 22px;
    background: rgba(8, 14, 28, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.btn-bug-primary {
    background: linear-gradient(135deg, #0284c7, #2563eb);
    color: #ffffff;
    border: 1px solid rgba(56, 189, 248, 0.4);
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(2, 132, 199, 0.35);
    transition: all 0.22s ease;
}

.btn-bug-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(2, 132, 199, 0.55);
    border-color: #38bdf8;
    filter: brightness(1.1);
}

.btn-bug-primary:active {
    transform: translateY(1px);
}

.btn-bug-health {
    background: rgba(16, 185, 129, 0.14);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.2s ease;
}

.btn-bug-health:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: #34d399;
    color: #6ee7b7;
    transform: translateY(-1px);
}

.btn-bug-purge {
    background: rgba(245, 158, 11, 0.16);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.2s ease;
}

.btn-bug-purge:hover {
    background: rgba(245, 158, 11, 0.28);
    border-color: #f59e0b;
    color: #fef3c7;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}

.btn-bug-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.09);
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-bug-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

.btn-bug-test {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.28);
}

.btn-bug-test:hover {
    background: rgba(245, 158, 11, 0.22);
    border-color: #fbbf24;
    color: #fef3c7;
}

/* Pestañas de filtrado */
.bug-modal-tabs {
    display: flex;
    padding: 10px 22px 0 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    gap: 8px;
    background: rgba(6, 10, 20, 0.95);
    overflow-x: auto;
}

.bug-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #94a3b8;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.bug-tab-btn:hover {
    color: #e2e8f0;
}

.bug-tab-btn.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

.bug-tab-count {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
}

.bug-tab-btn.active .bug-tab-count {
    background: rgba(56, 189, 248, 0.25);
    color: #38bdf8;
}

/* Cuerpo con Scroll */
.bug-modal-body {
    padding: 18px 22px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Tarjeta informativa / Resumen de Entorno */
.bug-env-banner {
    background: rgba(14, 23, 44, 0.55);
    border: 1px solid rgba(56, 189, 248, 0.15);
    border-radius: 14px;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    font-size: 12px;
}

.bug-env-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bug-env-item-label {
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.bug-env-item-val {
    color: #cbd5e1;
    font-weight: 600;
    word-break: break-all;
}

/* Lista de Errores e Incidentes */
.bug-logs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bug-empty-state {
    text-align: center;
    padding: 38px 20px;
    color: #64748b;
}

.bug-empty-state-icon {
    font-size: 42px;
    margin-bottom: 10px;
    display: inline-block;
}

.bug-empty-state h4 {
    color: #e2e8f0;
    margin: 0 0 6px 0;
    font-size: 15px;
}

.bug-empty-state p {
    font-size: 13px;
    margin: 0;
}

/* Tarjeta de Evento / Error */
.bug-log-card {
    background: rgba(11, 18, 32, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s;
}

.bug-log-card:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

.bug-log-card.severity-error {
    border-left: 4px solid #ef4444;
    background: rgba(25, 12, 16, 0.65);
}

.bug-log-card.severity-network {
    border-left: 4px solid #f97316;
    background: rgba(28, 16, 12, 0.65);
}

.bug-log-card.severity-warning {
    border-left: 4px solid #f59e0b;
    background: rgba(26, 20, 12, 0.65);
}

.bug-log-card.severity-success {
    border-left: 4px solid #10b981;
    background: rgba(12, 26, 20, 0.65);
}

.bug-log-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.bug-log-type-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.severity-error .bug-log-type-tag {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.severity-network .bug-log-type-tag {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
}

.severity-warning .bug-log-type-tag {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.severity-success .bug-log-type-tag {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.bug-log-time {
    color: #64748b;
    font-size: 11px;
    font-family: monospace;
}

.bug-log-msg {
    color: #f1f5f9;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}

.bug-log-loc {
    color: #38bdf8;
    font-size: 11.5px;
    font-family: monospace;
    word-break: break-all;
}

.bug-log-details-toggle {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 11.5px;
    cursor: pointer;
    padding: 4px 0 0 0;
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bug-log-details-toggle:hover {
    color: #e2e8f0;
}

.bug-log-stack {
    background: #040711;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    color: #cbd5e1;
    white-space: pre-wrap;
    overflow-x: auto;
    line-height: 1.4;
    max-height: 180px;
    display: none;
}

.bug-log-stack.open {
    display: block;
}

/* Cuadro de Notificación Toast dentro del Detector */
.bug-toast-feedback {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #0284c7;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(2, 132, 199, 0.5);
    z-index: 10000001;
    opacity: 0;
    pointer-events: none;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.bug-toast-feedback.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Pie del Modal */
.bug-modal-footer {
    padding: 12px 22px;
    background: rgba(10, 18, 36, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #64748b;
}

.bug-shortcut-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bug-key {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 10px;
    color: #cbd5e1;
}

/* Responsividad para móviles */
@media (max-width: 768px) {
    .bug-hud-pill {
        top: calc(14px + env(safe-area-inset-top, 0px));
        bottom: auto;
        left: 12px;
        padding: 5px 10px;
        font-size: 11.5px;
        background: rgba(8, 14, 28, 0.94);
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
    }

    .bug-modal-window {
        max-height: 94vh;
        border-radius: 16px;
    }

    .bug-modal-header,
    .bug-modal-actions-bar,
    .bug-modal-body,
    .bug-modal-footer {
        padding-left: 14px;
        padding-right: 14px;
    }

    .btn-bug-primary,
    .btn-bug-health {
        width: 100%;
        justify-content: center;
    }
}

/* Ocultar el HUD flotante cuando cualquier modal del catálogo esté abierto */
body.modal-abierto #bug-hud-pill,
body.modal-abierto .bug-hud-pill {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

