/* Variables CSS para temas */
:root {
    /* Colores base - Tema Light */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-header: #2c3e50;
    --text-primary: #333333;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --message-user-bg: #3498db;
    --message-user-text: #ffffff;
    --message-bot-bg: #ffffff;
    --message-bot-text: #333333;
    --input-bg: #ffffff;
    --input-border: #ddd;
    --quick-btn-bg: #f8f9fa;
    --quick-btn-border: #e9ecef;
    --quick-btn-hover: #e9ecef;
    --response-bg: rgba(16, 163, 127, 0.05);
    --response-border: rgba(16, 163, 127, 0.2);
    --route-bg: #2a2b32;
    --route-text: #ffffff;
}

[data-theme="dark"] {
    /* Colores base - Tema Dark MEJORADO */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-header: #111827;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --message-user-bg: #2563eb;
    --message-user-text: #ffffff;
    --message-bot-bg: #262626;
    --message-bot-text: #ffffff;
    --input-bg: #1f1f1f;
    --input-border: #404040;
    --quick-btn-bg: #2d2d2d;
    --quick-btn-border: #404040;
    --quick-btn-hover: #404040;
    --response-bg: rgba(16, 163, 127, 0.15);
    --response-border: rgba(16, 163, 127, 0.4);
    --route-bg: #000000;
    --route-text: #ffffff;
}

/* ========== ESTILOS BASE ========== */
.chat-flotante-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Botón flotante */
.chat-flotante-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10a37f, #0d8c6d);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(16, 163, 127, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-flotante-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(16, 163, 127, 0.4);
}

.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Ventana del chat - USANDO VARIABLES */
.chat-flotante-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 400px;
    height: 600px;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s ease;
}

.chat-flotante-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Header del chat - USANDO VARIABLES */
.chat-flotante-header {
    background: var(--bg-header);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: #10a37f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-header-text {
    line-height: 1.3;
}

.chat-title {
    font-weight: 600;
    font-size: 14px;
}

.chat-status {
    font-size: 11px;
    opacity: 0.8;
}

.chat-header-actions {
    display: flex;
    gap: 5px;
}

.chat-action-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Área de mensajes - USANDO VARIABLES */
.chat-flotante-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    display: flex;
    gap: 10px;
    max-width: 100%;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.user-chat {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #10a37f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.chat-message.user-chat .message-avatar {
    background: #3498db;
}

.message-content {
    max-width: 85%;
}

/* Message bubble - USANDO VARIABLES */
.message-bubble {
    background: var(--message-bot-bg);
    color: var(--message-bot-text);
    padding: 12px 15px;
    border-radius: 18px;
    box-shadow: 0 2px 8px var(--shadow-color);
    line-height: 1.4;
    font-size: 14px;
}

.chat-message.user-chat .message-bubble {
    background: var(--message-user-bg);
    color: var(--message-user-text);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 5px;
    text-align: right;
}

.chat-message.assistant .message-time {
    text-align: left;
}

/* Respuestas predefinidas - USANDO VARIABLES */
.predefined-response {
    background: var(--response-bg);
    border: 1px solid var(--response-border);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    font-size: 13px;
    color: var(--text-primary);
}

.predefined-response h4 {
    color: #10a37f;
    margin-bottom: 8px;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.route-path {
    background: var(--route-bg);
    color: var(--route-text);
    padding: 6px 10px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    margin: 8px 0;
    border-left: 3px solid #10a37f;
    font-size: 0.8em;
}

.predefined-response ol {
    margin: 10px 0;
    padding-left: 15px;
}

.predefined-response li {
    margin-bottom: 4px;
    padding-left: 4px;
    font-size: 0.9em;
    color: var(--text-primary);
}

.predefined-response ul {
    margin: 4px 0;
    padding-left: 15px;
}

.predefined-response ul li {
    margin-bottom: 2px;
    color: var(--text-secondary);
    font-size: 0.85em;
}

.predefined-response .tip {
    background: rgba(254, 178, 35, 0.1);
    border-left: 3px solid #feb223;
    padding: 6px 10px;
    border-radius: 4px;
    margin-top: 8px;
    font-size: 0.8em;
    color: var(--text-secondary);
}

/* Opciones de desambiguación - USANDO VARIABLES */
.disambiguation-container {
    background: rgba(86, 88, 105, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    color: var(--text-primary);
}

.disambiguation-container h4 {
    color: #10a37f;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.disambiguation-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.disambiguation-option {
    background: var(--quick-btn-bg);
    border: 1px solid var(--quick-btn-border);
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.disambiguation-option:hover {
    background: var(--quick-btn-hover);
    border-color: var(--text-secondary);
}

.disambiguation-title {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
}

.disambiguation-description {
    font-size: 0.8em;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Input y acciones rápidas - USANDO VARIABLES */
.chat-flotante-input-container {
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.chat-input-wrapper {
    position: relative;
    padding: 15px;
}

.chat-flotante-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 25px;
    padding: 12px 50px 12px 15px;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    max-height: 100px;
    font-family: inherit;
    color: var(--text-primary);
}

.chat-flotante-input:focus {
    outline: none;
    border-color: #10a37f;
}

.chat-send-btn {
    position: absolute;
    right: 20px;
    bottom: 20px;
    background: #10a37f;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: #0d8c6d;
}

.chat-quick-actions {
    padding: 0 15px 15px;
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.chat-quick-btn {
    background: var(--quick-btn-bg);
    border: 1px solid var(--quick-btn-border);
    border-radius: 16px;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    color: var(--text-primary);
}

.chat-quick-btn:hover {
    background: var(--quick-btn-hover);
    border-color: #10a37f;
    color: #10a37f;
}

/* Botón de acceso directo */
.quick-access {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
    text-align: center;
}

.access-btn {
    background: linear-gradient(135deg, #10a37f, #0d8c6d);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.3);
}

.access-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 163, 127, 0.4);
    background: linear-gradient(135deg, #0d8c6d, #0b765a);
}

.access-btn:active {
    transform: translateY(0);
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    color: var(--text-secondary);
    font-size: 12px;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}
.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Estados del chat */
.chat-flotante-window.minimized {
    height: 60px;
    overflow: hidden;
}

.chat-flotante-window.minimized .chat-flotante-messages,
.chat-flotante-window.minimized .chat-flotante-input-container {
    display: none;
}

/* Scrollbar personalizado */
.chat-flotante-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-flotante-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chat-flotante-messages::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 3px;
}

.chat-flotante-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

/* Scrollbar específico para dark */
[data-theme="dark"] .chat-flotante-messages::-webkit-scrollbar-track {
    background: #1a1a1a;
}

[data-theme="dark"] .chat-flotante-messages::-webkit-scrollbar-thumb {
    background: #555;
}

[data-theme="dark"] .chat-flotante-messages::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-flotante-container {
        bottom: 10px;
        right: 10px;
    }

    .chat-flotante-window {
        width: calc(100vw - 20px);
        height: 70vh;
        right: -10px;
    }

    .chat-flotante-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* Animaciones */
@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.chat-flotante-btn.pulse {
    animation: pulse 2s infinite;
}

/* Transiciones suaves para cambios de tema */
.chat-flotante-window,
.chat-flotante-messages,
.message-bubble,
.chat-flotante-input,
.chat-quick-btn,
.predefined-response,
.disambiguation-option {
    transition: background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease,
        box-shadow 0.3s ease;
}

/* Botón de tema en el header */
.chat-action-btn#themeToggleBtn {
    position: relative;
    overflow: hidden;
}

.chat-action-btn#themeToggleBtn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: width 0.3s, height 0.3s, top 0.3s, left 0.3s;
}

.chat-action-btn#themeToggleBtn:active::after {
    width: 100px;
    height: 100px;
    top: -30px;
    left: -30px;
}
/* ========== ESTILOS DE NOTIFICACIONES ========== */
.chat-notification-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    max-width: 300px;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    border-left: 4px solid #3498db;
}

.chat-notification-toast.show {
    transform: translateX(0);
}

.chat-notification-toast.info {
    border-left-color: #3498db;
}

.chat-notification-toast.success {
    border-left-color: #27ae60;
}

.chat-notification-toast.warning {
    border-left-color: #f39c12;
}

.chat-notification-toast.error {
    border-left-color: #e74c3c;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 25px;
}

.notification-content i {
    font-size: 18px;
}

.notification-content i.fa-info-circle {
    color: #3498db;
}
.notification-content i.fa-check-circle {
    color: #27ae60;
}
.notification-content i.fa-exclamation-triangle {
    color: #f39c12;
}
.notification-content i.fa-exclamation-circle {
    color: #e74c3c;
}

.notification-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.notification-close:hover {
    background: #f8f9fa;
    color: #e74c3c;
}

/* En móviles, el chat ocupa toda la pantalla */
@media (max-width: 768px) {
    .chat-flotante-window.active {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}
/* Tema dark para notificaciones */
[data-theme="dark"] .chat-notification-toast {
    background: #2d2d2d;
    color: white;
    border-left-color: #3498db;
}

[data-theme="dark"] .notification-close:hover {
    background: #404040;
}
/* ESTILOS PARA EL CHAT */
.chat-flotante-container {
    z-index: 10000;
}

/* Chat CERRADO - oculto visualmente pero presente en DOM */
.chat-flotante-window {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Chat ABIERTO */
.chat-flotante-window.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    cursor: pointer;
}

/* Botón flotante siempre visible */
.chat-flotante-btn {
    z-index: 10001;
}




/* Modal para zoom de imágenes */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    z-index: 10001;
}

.close-modal:hover {
    color: #bbb;
}

/* Hacer que las imágenes en el chat sean clickeables */
.predefined-response img {
    cursor: pointer;
    transition: transform 0.2s;
}

.predefined-response img:hover {
    transform: scale(1.02);
}