/* Consola de Desarrollo - Estilos */
/* Estilos específicos para Picture-in-Picture */
.dev-console.pip-mode {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0;
    box-shadow: none;
}

.dev-console.pip-mode .console-header {
    cursor: default;
    -webkit-app-region: drag; /* Permite arrastrar la ventana PiP */
}

.dev-console.pip-mode .console-controls {
    -webkit-app-region: no-drag; /* Evita que los botones arrastren */
}

.pip-badge {
    background: #ff6b6b;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 8px;
}

.console-pip {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.console-pip:hover {
    background: rgba(100, 116, 139, 0.1);
    color: #334155;
}

/* Estilos para el contenedor PiP */
#pip-console-container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ajustes para el documento PiP */
:root {
    --pip-console-bg: #1a1a1a;
    --pip-console-text: #e5e7eb;
    --pip-console-border: #374151;
}

/* Estilos base para el documento PiP */
.pip-mode * {
    box-sizing: border-box;
}

/* Ocultar elementos no necesarios en PiP */
.pip-mode .drag-indicator {
    display: none;
}

.pip-mode .resize-handle {
    display: none;
}


.dev-console {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-elevated, #23272f);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-primary, rgba(255,255,255,0.2));
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    color: var(--text-primary, #fff);
    font-family: 'Consolas', 'Monaco', 'Lucida Console', monospace;
    font-size: 12px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
    min-height: 200px;
    max-width: calc(100vw - 100px);
    max-height: calc(100vh - 100px);
    resize: none; /* Desactivamos el resize nativo */
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10001;
    pointer-events: auto;
}

.resize-right {
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
}

.resize-bottom {
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 6px;
    cursor: ns-resize;
}

.resize-left {
    top: 0;
    left: -3px;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
}

.resize-top {
    top: -3px;
    left: 0;
    width: 100%;
    height: 6px;
    cursor: ns-resize;
}

.resize-bottom-right {
    bottom: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    cursor: nw-resize;
}

.resize-bottom-left {
    bottom: -3px;
    left: -3px;
    width: 12px;
    height: 12px;
    cursor: ne-resize;
}

.resize-top-right {
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    cursor: ne-resize;
}

.resize-top-left {
    top: -3px;
    left: -3px;
    width: 12px;
    height: 12px;
    cursor: nw-resize;
}

/* Indicadores visuales para resize handles */
.resize-handle:hover {
    background: var(--accent-primary-alpha, rgba(99,102,241,0.1));
    transition: background 0.1s ease;
}

.resize-bottom-right::after,
.resize-bottom-left::after,
.resize-top-right::after,
.resize-top-left::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.resize-bottom-right:hover::after,
.resize-bottom-left:hover::after,
.resize-top-right:hover::after,
.resize-top-left:hover::after {
    opacity: 1;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Header de la consola */
.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface-primary, #1a1a2e);
    border-bottom: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
    pointer-events: auto;
}

.console-header:active {
    cursor: grabbing;
}

.dev-console.dragging .console-header {
    cursor: grabbing;
}

.console-title {
    display: flex;
    align-items: center;
    font-weight: bold;
    font-size: 13px;
}

.console-icon {
    margin-right: 8px;
    font-size: 16px;
    animation: pulse 2s infinite;
    color: var(--accent-primary, #6366f1);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.message-count {
    font-size: 10px;
    background: var(--accent-primary-alpha, rgba(99,102,241,0.2));
    padding: 2px 6px;
    border-radius: var(--radius-sm, 8px);
    color: var(--text-primary, #fff);
}

.console-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.console-controls button,
.console-filter-btn,
.console-export,
.console-clear,
.console-close {
    background: none;
    border: none;
    color: var(--text-primary, #fff);
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: 12px;
    transition: color 0.2s;
    box-shadow: none;
}

.console-controls button:hover,
.console-filter-btn:hover,
.console-export:hover,
.console-clear:hover,
.console-close:hover {
    color: var(--accent-primary, #6366f1);
    background: none;
    border: none;
}

.console-filter {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    outline: none;
    cursor: pointer;
    pointer-events: auto;
}

.console-filter:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.console-filter option {
    background: #1a1a1a;
    color: #ffffff;
}

.console-clear,
.console-close,
.console-export {
    background: var(--surface-secondary, #16213e);
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.2));
    color: var(--text-primary, #fff);
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.console-export:hover {
    background: var(--accent-primary-alpha, rgba(99,102,241,0.2));
    border-color: var(--accent-primary, #6366f1);
}

.console-clear:hover {
    color: var(--error-bg, #dc2626);
}

.console-close:hover {
    color: var(--error-hover, #b91c1c);
}

/* Cuerpo de la consola */
.console-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--surface-primary, #1a1a2e);
}

.console-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    line-height: 1.4;
    background: transparent;
}

/* Scrollbar personalizada */
.console-messages::-webkit-scrollbar {
    width: 6px;
}

.console-messages::-webkit-scrollbar-track {
    background: var(--surface-secondary, #16213e);
}

.console-messages::-webkit-scrollbar-thumb {
    background: var(--accent-primary-alpha, rgba(99,102,241,0.2));
    border-radius: 3px;
}

.console-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary, #6366f1);
}

/* Mensajes individuales */
.console-message {
    display: flex;
    gap: 8px;
    margin-bottom: 2px;
    padding: 2px 0;
    word-wrap: break-word;
    align-items: flex-start;
    border-radius: var(--radius-sm, 4px);
}

.console-message:hover {
    background: var(--surface-hover, #2d2d5a);
    margin: 0 -8px;
    padding: 2px 8px;
}

.message-timestamp {
    color: var(--text-disabled, #888);
    font-size: 10px;
    min-width: 80px;
    flex-shrink: 0;
}

.message-role {
    font-weight: bold;
    font-size: 10px;
    min-width: 60px;
    flex-shrink: 0;
    text-align: center;
    color: var(--accent-primary, #6366f1) !important;
}

.message-content {
    flex: 1;
    color: var(--text-primary, #fff);
    white-space: pre-wrap;
}

/* Estilos específicos por rol */
.console-info .message-content {
    color: #5ecbfa !important; /* Azul pastel, forzado */
    font-weight: bold;
    filter: brightness(1.1) saturate(1.1);
}

.console-pensamiento .message-content {
    color: #fbbf24;
    font-weight: bold;
    filter: brightness(1.3) saturate(1.2);
    font-style: italic;
}

.console-tool .message-content {
    color: #22c55e;
    font-weight: bold;
    filter: brightness(1.3) saturate(1.2);
}

.console-assistant .message-content {
    color: var(--text-primary, #fff);
}

.console-error .message-content {
    color: var(--error-bg, #dc2626);
    font-weight: bold;
    filter: brightness(1.3) saturate(1.2);
}

.console-warning .message-content {
    color: #f59e42;
    font-weight: bold;
    filter: brightness(1.3) saturate(1.2);
}

.console-success .message-content {
    color: #22c55e;
    font-weight: bold;
    filter: brightness(1.3) saturate(1.2);
}

.console-debug .message-content {
    color: var(--text-disabled, #888);
    font-style: italic;
    filter: brightness(1.3) saturate(1.2);
}

/* Footer de la consola */
.console-footer {
    padding: 4px 12px;
    background: var(--surface-secondary, #16213e);
    border-top: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    font-size: 10px;
}

.console-shortcuts {
    display: flex;
    gap: 16px;
    color: var(--text-disabled, #888);
}

.console-shortcuts span {
    display: flex;
    align-items: center;
}

/* Eliminar animaciones y transiciones globalmente en la consola */
.dev-console, .dev-console *,
.console-message, .console-message *,
.console-header, .console-header *,
.console-body, .console-body *,
.console-messages, .console-messages *,
.console-footer, .console-footer * {
    transition: none !important;
    animation: none !important;
}

/* Eliminar animación de entrada de mensajes */
.console-message {
    animation: none !important;
}

/* Estados de resizing y dragging */
.dev-console.resizing {
    transition: none;
}

.dev-console.resizing .console-messages,
.dev-console.dragging .console-messages {
    pointer-events: none;
}

.dev-console.resizing .console-body,
.dev-console.dragging .console-body {
    pointer-events: none;
}

.dev-console.dragging {
    transition: none !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
}

.dev-console.dragging,
.dev-console.dragging * {
    transition: none !important;
}

.dev-console.dragging .console-message,
.dev-console.dragging .message-content,
.dev-console.dragging .console-messages,
.dev-console.dragging .console-md-fragment,
.dev-console.dragging .message-role,
.dev-console.dragging .message-timestamp {
    transition: none !important;
    animation: none !important;
}

.dev-console.resizing .console-message,
.dev-console.resizing .message-content,
.dev-console.resizing .console-messages,
.dev-console.resizing .console-md-fragment,
.dev-console.resizing .message-role,
.dev-console.resizing .message-timestamp {
    transition: none !important;
    animation: none !important;
}

/* Panel de filtros de roles */
.console-filters {
    background: var(--surface-primary, #1a1a2e);
    border-bottom: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    padding: 12px;
    font-size: 11px;
    max-height: 200px;
    overflow-y: auto;
}

.filter-title {
    color: var(--accent-primary, #6366f1);
    font-weight: bold;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
    background: var(--surface-hover, #2d2d5a);
    border: 1px solid var(--border-light, rgba(255,255,255,0.1));
    transition: all 0.2s;
    font-size: 11px;
    user-select: none;
    min-width: fit-content;
}

.filter-checkbox:hover {
    background: var(--accent-primary-alpha, rgba(99,102,241,0.1));
    border-color: var(--accent-primary, #6366f1);
}

.filter-checkbox input[type="checkbox"] {
    display: none;
}

.filter-checkbox .checkmark {
    width: 12px;
    height: 12px;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.3));
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: var(--surface-secondary, #16213e);
    flex-shrink: 0;
}

.filter-checkbox input[type="checkbox"]:checked + .checkmark {
    border-color: var(--accent-primary, #6366f1);
    background: var(--accent-primary, #6366f1);
}

.filter-checkbox input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
}

.filter-checkbox input[type="checkbox"][value="assistant"]:checked + .checkmark::after {
    color: #111;
}

/* Botón del filtro */
.console-filter-btn {
    background: var(--surface-secondary, #16213e);
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.2));
    color: var(--text-primary, #fff);
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.console-filter-btn:hover {
    background: var(--accent-primary-alpha, rgba(99,102,241,0.2));
    border-color: var(--accent-primary, #6366f1);
}

/* Responsive para filtros */
@media (max-width: 600px) {
    .filter-checkboxes {
        flex-direction: column;
        gap: 4px;
    }
    
    .filter-checkbox {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .console-filters {
        max-height: 150px;
    }
}

@media (max-width: 768px) {
    .dev-console {
        left: 20px !important;
        right: 20px;
        transform: none !important;
        width: calc(100vw - 40px) !important;
        max-width: none;
        top: 20px !important;
    }
    
    .console-header {
        padding: 6px 8px;
        cursor: grab;
    }
    
    .console-title {
        font-size: 12px;
    }
    
    .console-controls {
        gap: 4px;
    }
    
    .console-filter {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .console-export,
    .console-clear,
    .console-close {
        min-width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .console-shortcuts {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .drag-indicator {
        display: none; /* Ocultar en móviles */
    }
}

/* Estados de foco para accesibilidad */
.console-filter:focus,
.console-export:focus,
.console-clear:focus,
.console-close:focus {
    outline: 2px solid var(--accent-primary-alpha, rgba(99,102,241,0.5));
    outline-offset: 2px;
}

/* Indicador de actividad */
.console-activity {
    position: absolute;
    top: 8px;
    right: 60px;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Estado vacío */
.console-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-disabled, #888);
    font-style: italic;
}

.console-empty .empty-icon {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.drag-indicator {
    margin-right: 8px;
    color: var(--text-disabled, rgba(255,255,255,0.4));
    font-size: 14px;
    font-weight: bold;
    transition: color 0.2s;
}

.console-header:hover .drag-indicator {
    color: var(--text-primary, #fff);
}

.console-body a,
.console-messages a,
.console-md-fragment a {
    color: #22c55e;
    font-weight: bold;
    filter: brightness(1.3) saturate(1.2);
    text-decoration: underline;
    transition: color 0.2s;
}

.console-body a:hover,
.console-messages a:hover,
.console-md-fragment a:hover {
    color: #a3e635;
    text-decoration: underline;
}
