/* ============ VFD CHATBOT (paleta oscura propia) ============ */

:root {
    --vfd-primary: #0194F2;
    --vfd-secondary: #8E3EBD;
    /* El chatbot es SIEMPRE oscuro para buen contraste */
    --vfd-win-bg: #121a2b;
    --vfd-body-bg: #0d1422;
    --vfd-bot-bubble: #1e2a44;
    --vfd-bot-text: #e8eefc;
    --vfd-user-bubble: #0194F2;
    --vfd-user-text: #ffffff;
    --vfd-input-bg: #1a2336;
    --vfd-input-text: #e8eefc;
    --vfd-border: #2a3550;
    --vfd-muted: #9fb0cc;
}

/* ===== Dark mode GLOBAL de la PAGINA (toggle claro/oscuro) ===== */
html.vfd-dark body { background-color: #0d1422 !important; color: #e8eefc; }

/* Superficies / secciones de todo el sitio */
html.vfd-dark section,
html.vfd-dark .bg-light,
html.vfd-dark .bg-white,
html.vfd-dark .card,
html.vfd-dark .module-content,
html.vfd-dark .sidebar-menu { background-color: #121a2b !important; color: #e8eefc; }

/* La hamburguesa NO debe oscurecerse: se mantiene clara y visible */
html.vfd-dark .navbar-toggler.bg-light { background-color: #f8f9fa !important; }

/* Hero oscurecido */
html.vfd-dark .hero-section {
    background: linear-gradient(rgba(8, 12, 22, 0.92), rgba(8, 12, 22, 0.85)),
                url('https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?auto=format&fit=crop&w=1920&q=80');
    background-size: cover;
    background-position: center;
}

/* Texto legible en cualquier página (incluye estilos inline azules) */
html.vfd-dark h1, html.vfd-dark h2, html.vfd-dark h3,
html.vfd-dark h4, html.vfd-dark h5, html.vfd-dark h6 { color: #e8eefc !important; }
html.vfd-dark p, html.vfd-dark li, html.vfd-dark small,
html.vfd-dark .card-text, html.vfd-dark .text-muted { color: #c9d4ea !important; }

/* Imágenes un poco más suaves en oscuro */
html.vfd-dark .card-img-top { filter: brightness(0.85); }

/* ---------- Contenedor / Boton flotante (FIJO) ---------- */
#vfd-chatbot-container {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 10000;
    font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
}

.vfd-chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--vfd-primary) 0%, var(--vfd-secondary) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(1, 148, 242, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0;
    transition: transform 0.25s ease;
}
.vfd-chatbot-toggle:hover { transform: scale(1.08); }
.vfd-chatbot-toggle:active { transform: scale(0.95); }
.vfd-chatbot-toggle svg { width: 26px; height: 26px; }

.vfd-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #FF6B9D 0%, #FF1493 100%);
    color: #fff;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    border: 2px solid #fff;
}

/* ---------- Ventana del chat (mas pequeña) ---------- */
.vfd-chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 22px;
    width: 340px;
    height: 470px;
    max-height: calc(100vh - 120px);
    background: var(--vfd-win-bg);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10001;
}

.vfd-chatbot-window.vfd-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px) scale(0.96);
    pointer-events: none;
}

.vfd-chatbot-window.vfd-maximized {
    width: min(780px, 92vw);
    height: 88vh;
    max-height: 88vh;
}

/* ---------- Header (zona de arrastre) ---------- */
.vfd-chatbot-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #0194F2 100%);
    color: #fff;
    padding: 10px 12px;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}
.vfd-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.vfd-header-icon {
    width: 30px; height: 30px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.vfd-header-icon svg { width: 26px; height: 26px; }
.vfd-header-title h6 { margin: 0; font-size: 15px; font-weight: 800; line-height: 1.1; }
.vfd-header-title small { display: block; font-size: 10px; opacity: 0.85; }

.vfd-header-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* Boton Hablar (micrófono) */
.vfd-mic-btn {
    display: flex; align-items: center; gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.vfd-mic-btn:hover { background: rgba(255, 255, 255, 0.32); }
.vfd-mic-btn.active { background: #ef4444; animation: vfdPulse 1.2s infinite; }
@keyframes vfdPulse { 50% { opacity: 0.6; } }

.vfd-controls-right { display: flex; align-items: center; gap: 8px; }

/* Control de tamaño de letra A- 100% A+ */
.vfd-font-control {
    display: flex; align-items: center;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 2px;
}
.vfd-font-control button {
    background: none; border: none; color: #fff;
    font-size: 12px; font-weight: 700;
    padding: 3px 8px; cursor: pointer;
}
.vfd-font-control button:hover { color: #aee3ff; }
.vfd-font-control span { font-size: 10px; width: 34px; text-align: center; opacity: 0.9; }

.vfd-icon-btn {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    border: none;
    width: 30px; height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.vfd-icon-btn:hover { background: rgba(255, 255, 255, 0.25); color: #fff; }
.vfd-icon-btn.vfd-close:hover { color: #ff9aa6; }
.vfd-icon-btn svg { width: 16px; height: 16px; }

/* ---------- Cuerpo / mensajes ---------- */
.vfd-chatbot-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: var(--vfd-body-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px; /* base; el control A-/A+ ajusta este valor */
}
.vfd-chatbot-body::-webkit-scrollbar { width: 6px; }
.vfd-chatbot-body::-webkit-scrollbar-thumb { background: var(--vfd-primary); border-radius: 3px; }

.vfd-message { display: flex; gap: 8px; width: 100%; }
.vfd-message.user { justify-content: flex-end; }

.vfd-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--vfd-primary), var(--vfd-secondary));
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
}

.vfd-bubble {
    max-width: 80%;
    background: var(--vfd-bot-bubble);
    color: var(--vfd-bot-text);
    padding: 10px 13px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    line-height: 1.45;
    font-size: 1em;
}
.vfd-message.user .vfd-bubble {
    background: var(--vfd-user-bubble);
    color: var(--vfd-user-text);
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

/* Fila de acciones por mensaje (Escuchar / Copiar) */
.vfd-msg-actions {
    display: flex; gap: 14px;
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}
.vfd-msg-btn {
    display: flex; align-items: center; gap: 5px;
    background: none; border: none; cursor: pointer;
    font-size: 0.85em; font-weight: 600;
    transition: opacity 0.2s;
}
.vfd-msg-btn.listen { color: #34d399; }
.vfd-msg-btn.copy { color: #38bdf8; }
.vfd-msg-btn:hover { opacity: 0.75; }
.vfd-msg-btn svg { width: 14px; height: 14px; }

/* ---------- Indicador de escritura ---------- */
.vfd-typing-indicator { display: flex; gap: 4px; padding: 4px 2px; }
.vfd-typing-indicator span {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--vfd-primary);
    animation: vfdTyping 1.4s infinite;
}
.vfd-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.vfd-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes vfdTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ---------- Input ---------- */
.vfd-chatbot-input-area {
    padding: 10px;
    border-top: 1px solid var(--vfd-border);
    background: var(--vfd-win-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.vfd-attach-btn {
    display: inline-flex; align-items: center; gap: 6px;
    align-self: flex-start;
    background: var(--vfd-bot-bubble);
    color: #38bdf8;
    border: none; border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.vfd-attach-btn:hover { background: #24314f; }
.vfd-attach-btn svg { width: 15px; height: 15px; }

.vfd-input-container { display: flex; gap: 6px; }
.vfd-input {
    flex: 1;
    border: 1px solid var(--vfd-border);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13px;
    background: var(--vfd-input-bg);
    color: var(--vfd-input-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.vfd-input::placeholder { color: var(--vfd-muted); }
.vfd-input:focus { border-color: var(--vfd-primary); box-shadow: 0 0 0 3px rgba(1, 148, 242, 0.15); }

.vfd-send-btn {
    border: none; border-radius: 8px;
    background: var(--vfd-primary); color: #fff;
    width: 42px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.vfd-send-btn:hover { background: #0170bf; }
.vfd-send-btn svg { width: 18px; height: 18px; }

/* ---------- Toggle Claro / Oscuro de la pagina (a la derecha) ---------- */
#vfd-theme-toggle {
    position: fixed;
    top: 8px;
    right: 20px;
    z-index: 9999;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    background: linear-gradient(135deg, #243b5e 0%, #1a2a44 100%);
    color: #eaf2ff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
#vfd-theme-toggle svg { width: 22px; height: 22px; }
#vfd-theme-toggle:hover { transform: scale(1.1) rotate(12deg); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); }
html.vfd-dark #vfd-theme-toggle {
    background: linear-gradient(135deg, #ffd96b 0%, #f5b942 100%);
    color: #3a2c05;
    border-color: rgba(0, 0, 0, 0.12);
}

/* ---------- Responsivo ---------- */

/* MÓVIL: hamburguesa + toggle de tema juntos arriba-derecha, título debajo */
@media (max-width: 991.98px) {
    .navbar-custom .container { flex-wrap: wrap; row-gap: 6px; }
    /* Hamburguesa a la derecha, dejando hueco para el toggle (ambos arriba-derecha) */
    .navbar-custom .navbar-toggler { order: 1; margin-left: auto; margin-right: 56px; }
    .navbar-custom .navbar-brand {
        order: 2;
        width: 100%;
        margin-right: 0;
        margin-top: 4px;
    }
    .navbar-custom .navbar-collapse { order: 3; width: 100%; }

    /* Toggle claro/oscuro pegado al borde derecho, separado de la hamburguesa */
    #vfd-theme-toggle {
        top: 11px;
        right: 14px;
        width: 40px;
        height: 40px;
        font-size: 17px;
        z-index: 1080; /* por encima de la navbar sticky */
    }
}

@media (max-width: 576px) {
    #vfd-chatbot-container { bottom: 14px; right: 14px; }
    .vfd-chatbot-window {
        width: calc(100vw - 24px);
        right: 12px;
        height: 72vh;
        max-height: 72vh;
    }
    .vfd-chatbot-window.vfd-maximized { width: calc(100vw - 16px); height: 90vh; max-height: 90vh; }
}
