/* 1. RESET Y BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: #f8fafc;
    color: #334155;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1.5rem;
    min-height: 100vh;
}

/* 2. ENCABEZADO Y NAVEGACIÓN */
.cabecera {
    text-align: center;
    margin-bottom: 3rem;
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cabecera h1 {
    font-size: 2.5rem;
    color: #0f172a;
    margin-bottom: 0.75rem;
}

.cabecera p {
    font-size: 1.1rem;
    color: #64748b;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.menu-navegacion {
    display: inline-flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    background: #ffffff;
    padding: 0.5rem;
    border-radius: 99px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-nav {
    background: transparent;
    color: #64748b;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-nav:hover:not(.disabled) {
    color: #0f172a;
    background: #f1f5f9;
}

.btn-nav.activo {
    background: #2563eb;
    color: #ffffff;
}

.btn-nav.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.vista-seccion {
    animation: aparecer 0.3s ease-in-out;
    width: 100%;
}

@keyframes aparecer {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 3. LAYOUT PRINCIPAL */
.contenedor-principal {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.contenedor-resultados {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    align-items: stretch;
}

.columna-principal {
    flex: 1; 
    min-width: 0;
}

.columna-alternativas {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 4. PANELES Y TARJETAS */
.panel-filtros {
    background: #ffffff;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    margin-bottom: 2rem;
}

.grupo-filtro h3 {
    font-size: 1rem;
    color: #475569;
    margin-bottom: 1.5rem !important;
    font-weight: 600;
}

.botones-opciones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem !important;
}

.btn-opcion {
    background: #f1f5f9;
    color: #475569;
    border: 2px solid transparent;
    padding: 0.75rem 1.25rem;
    border-radius: 99px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-opcion:hover {
    background: #e2e8f0;
}

.btn-opcion.seleccionado {
    background: #eff6ff;
    color: #2563eb;
    border-color: #2563eb;
    font-weight: 600;
}

.tarjeta-modelo {
    background: #ffffff;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    border-top: 4px solid #2563eb; 
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tarjeta-mini {
    background: #ffffff;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    text-align: left;
}

.tarjeta-mini:hover {
    border-color: #93c5fd;
    transform: translateY(-2px);
}

/* 5. TIPOGRAFÍA Y ETIQUETAS */
.etiqueta-recomendado {
    background: #dbeafe;
    color: #1d4ed8;
    padding: 0.4rem 0.8rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.etiqueta-alternativa {
    background: #f1f5f9;
    color: #475569;
}

.tarjeta-modelo h2 {
    font-size: 2.2rem;
    color: #0f172a;
    margin: 1.5rem 0 0.5rem 0;
    word-break: break-word; 
    overflow-wrap: anywhere;
}

.tarjeta-modelo p {
    color: #64748b;
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

.tarjeta-mini h4 {
    font-size: 1.1rem;
    color: #0f172a;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word; 
}

.tarjeta-mini p {
    font-size: 0.85rem;
    color: #64748b;
}

/* 6. COMPONENTES TERMINAL */
.caja-comando {
    background: #1e293b;
    border-radius: 8px;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    gap: 1rem;
}

.caja-comando code {
    color: #10b981; 
    font-family: monospace;
    font-size: 1.1rem;
    text-align: left;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.btn-copiar {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-copiar:hover {
    background: #1d4ed8; 
}

.link-detalles {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
}

.link-detalles:hover {
    color: #64748b;
    text-decoration: underline;
}

/* 8. CATÁLOGO: CONTROLES Y GRID */
.controles-catalogo {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.input-cat, .select-cat {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.95rem;
    color: #334155;
    background-color: #f8fafc;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-cat {
    flex: 1;
    min-width: 200px;
}

.select-cat {
    cursor: pointer;
    min-width: 180px;
}

.input-cat:focus, .select-cat:focus {
    border-color: #2563eb;
}

.grid-catalogo {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

/* 9. VENTANA MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}

.modal-contenido {
    position: relative;
    max-width: 600px;
    width: 100%;
    height: auto;
    padding: 2.5rem;
    animation: aparecer 0.3s ease-out;
}

.btn-cerrar {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    font-size: 2rem;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
    z-index: 10;
}

.modal-contenido .etiqueta-recomendado {
    margin-top: 1rem;
    align-self: center;
}

.btn-cerrar:hover {
    color: #0f172a;
}

/* 10. ADAPTABILIDAD MÓVIL */
@media (max-width: 768px) {
    .contenedor-resultados {
        flex-direction: column;
    }

    .columna-alternativas {
        flex: 1;
        width: 100%;
    }

    .menu-navegacion {
        flex-wrap: wrap;
        border-radius: 16px;
    }

    .btn-nav {
        width: 100%;
    }

    .tarjeta-modelo {
        padding: 1rem;
    }

    .caja-comando {
        flex-direction: column;
        gap: 1rem;
    }

    .caja-comando code {
        text-align: center;
    }

    .btn-copiar {
        width: 100%;
    }

    .controles-catalogo {
        flex-direction: column;
    }
    
    .input-cat, .select-cat {
        width: 100%;
    }
}

/* 11. MODO OSCURO */
body.dark-mode {
    background-color: #0f172a;
    color: #cbd5e1;
}

body.dark-mode .cabecera h1,
body.dark-mode .tarjeta-modelo h2,
body.dark-mode .tarjeta-mini h4,
body.dark-mode .tarjeta-catalogo h4,
body.dark-mode .grupo-filtro h3,
body.dark-mode .titulo-filtro,
body.dark-mode .panel-filtros h2 {
    color: #f1f5f9 !important;
}

body.dark-mode .cabecera p,
body.dark-mode .tarjeta-modelo p,
body.dark-mode .tarjeta-mini p {
    color: #94a3b8;
}

body.dark-mode .panel-filtros,
body.dark-mode .tarjeta-modelo,
body.dark-mode .tarjeta-mini,
body.dark-mode .menu-navegacion,
body.dark-mode .tarjeta-catalogo,
body.dark-mode .modal-contenido {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

body.dark-mode .btn-opcion {
    background: #334155;
    color: #cbd5e1;
}

body.dark-mode .btn-opcion:hover {
    background: #475569;
}

body.dark-mode .btn-opcion.seleccionado {
    background: #1e3a8a;
    color: #60a5fa;
    border-color: #3b82f6;
}

body.dark-mode .btn-nav {
    color: #94a3b8;
}

body.dark-mode .btn-nav:hover:not(.disabled):not(.activo) {
    background: #334155;
    color: #f1f5f9;
}

body.dark-mode .input-cat, 
body.dark-mode .select-cat {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-mode .tag,
body.dark-mode .etiqueta-alternativa {
    background: #334155;
    color: #cbd5e1;
}

body.dark-mode .btn-cerrar {
    color: #64748b;
}

body.dark-mode .btn-cerrar:hover {
    color: #f1f5f9;
}

body.dark-mode .caja-comando,
body.dark-mode .btn-copiar-mini {
    background-color: #020617;
    border: 1px solid #334155;
}

body.dark-mode .etiqueta-recomendado {
    background-color: #1e3a8a;
    color: #bfdbfe;
}

/* 12. CHAT ASISTENTE IA - FORZANDO TAMAÑO Y BOTONES */
.contenedor-chat.tarjeta-modelo {
    display: flex;
    flex-direction: column;
    height: 80vh !important;
    min-height: 600px !important;
    width: 100%;
    padding: 0 !important; 
    overflow: hidden;
    margin: 0;
}

.cabecera-chat {
    padding: 1.5rem !important;
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
    flex-shrink: 0; 
}

.cabecera-chat h2 {
    font-size: 2rem !important;
    margin-bottom: 0.5rem !important;
}

.cabecera-chat p {
    font-size: 1.2rem !important;
    margin-bottom: 0.5rem !important;
}

.nota-servidor {
    color: #94a3b8 !important;
    font-size: 0.95rem !important;
    margin: 0 !important;
}

.historial-chat {
    flex-grow: 1;
    padding: 2rem !important;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    background-color: #f8fafc;
    text-align: left;
}

.mensaje {
    display: flex;
    max-width: 80%;
}

.burbuja {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-size: 1.1rem !important;
    line-height: 1.6;
}

.mensaje.user {
    align-self: flex-end;
}

.mensaje.ai {
    align-self: flex-start;
}

.mensaje.user .burbuja {
    background-color: #2563eb;
    color: white;
    border-bottom-right-radius: 4px;
}

.mensaje.ai .burbuja {
    background-color: #e2e8f0;
    color: #334155;
    border-bottom-left-radius: 4px;
}

.entrada-chat {
    padding: 1.5rem !important;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 0.75rem;
    background: white;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 1.1rem !important;
}

#chat-input:focus {
    border-color: #2563eb;
}

#btn-enviar-chat {
    padding: 1rem 1.5rem;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

#btn-enviar-chat:hover {
    background-color: #1d4ed8;
}

body.dark-mode .cabecera-chat,
body.dark-mode .entrada-chat {
    border-color: #334155;
    background: #1e293b;
}

body.dark-mode .historial-chat {
    background-color: #0f172a;
}

body.dark-mode .mensaje.ai .burbuja {
    background-color: #334155;
    color: #e2e8f0;
}

body.dark-mode #chat-input {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.25rem 0.5rem;
    height: 24px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #64748b;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

body.dark-mode .typing-indicator span {
    background-color: #94a3b8;
}

/* CAJA DE COMANDO EXCLUSIVA DEL CHAT */
.caja-comando-chat {
    background: #0f172a;
    padding: 10px;
    border-radius: 8px;
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #334155;
}

.caja-comando-chat code {
    color: #10b981;
    font-family: monospace;
    font-size: 0.95rem;
}

.btn-copiar-chat {
    background: #2563eb;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 10px;
}

.btn-copiar-chat:hover {
    background: #1d4ed8;
}

body.dark-mode .caja-comando-chat {
    background: #020617;
}