/**
 * CHATBOT IA PARA ESTUDIANTES - ESTILOS
 * =======================================
 * Diseño: Panel lateral (sidebar) deslizable
 * Tema: Moderno, limpio, profesional
 * Responsive: Adaptado a móviles y tablets
 * 
 * @version 1.0.0
 */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --chatbot-primary: #4f46e5;
    --chatbot-primary-dark: #4338ca;
    --chatbot-primary-light: #6366f1;
    --chatbot-secondary: #10b981;
    --chatbot-danger: #ef4444;
    --chatbot-warning: #f59e0b;
    
    --chatbot-bg: #ffffff;
    --chatbot-bg-light: #f9fafb;
    --chatbot-bg-dark: #1f2937;
    
    --chatbot-text: #111827;
    --chatbot-text-light: #6b7280;
    --chatbot-text-inverse: #ffffff;
    
    --chatbot-border: #e5e7eb;
    --chatbot-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --chatbot-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
    
    --chatbot-panel-width: 420px;
    --chatbot-panel-width-mobile: 100%;
    
    --chatbot-z-index: 9999;
}

/* ============================================
   BOTÓN FLOTANTE (Toggle)
   ============================================ */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-light));
    color: var(--chatbot-text-inverse);
    border: none;
    box-shadow: var(--chatbot-shadow);
    cursor: pointer;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: var(--chatbot-z-index);
    animation: chatbot-pulse 2s infinite;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--chatbot-shadow-lg);
    animation: none;
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle.chatbot-toggle-oculto {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

/* Badge de notificaciones */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chatbot-danger);
    color: white;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

/* Animación de pulso */
@keyframes chatbot-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(79, 70, 229, 0);
    }
}

/* ============================================
   PANEL LATERAL (Sidebar)
   ============================================ */
.chatbot-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: var(--chatbot-panel-width);
    height: 100vh;
    background: var(--chatbot-bg);
    box-shadow: var(--chatbot-shadow-lg);
    z-index: var(--chatbot-z-index);
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-panel-abierto {
    right: 0;
}

/* ============================================
   HEADER
   ============================================ */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-light));
    color: var(--chatbot-text-inverse);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-info i {
    font-size: 28px;
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chatbot-header-info small {
    display: block;
    opacity: 0.9;
    font-size: 12px;
    margin-top: 2px;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ============================================
   ACCIONES RÁPIDAS
   ============================================ */
.chatbot-acciones-rapidas {
    display: flex;
    gap: 8px;
    padding: 15px;
    background: var(--chatbot-bg-light);
    border-bottom: 1px solid var(--chatbot-border);
    overflow-x: auto;
    flex-shrink: 0;
}

.chatbot-acciones-rapidas::-webkit-scrollbar {
    height: 4px;
}

.chatbot-acciones-rapidas::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 4px;
}

.chatbot-accion-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: white;
    border: 1px solid var(--chatbot-border);
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    min-width: 80px;
}

.chatbot-accion-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.chatbot-accion-btn i {
    font-size: 20px;
}

.chatbot-accion-btn span {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* ============================================
   ÁREA DE MENSAJES
   ============================================ */
.chatbot-mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chatbot-bg-light);
    scroll-behavior: smooth;
}

.chatbot-mensajes::-webkit-scrollbar {
    width: 6px;
}

.chatbot-mensajes::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-mensajes::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 10px;
}

.chatbot-mensajes::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-text-light);
}

/* ============================================
   MENSAJES
   ============================================ */
.chatbot-mensaje {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: chatbot-mensaje-aparecer 0.3s ease;
}

@keyframes chatbot-mensaje-aparecer {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-mensaje-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chatbot-mensaje-contenido {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    line-height: 1.6;
}

.chatbot-mensaje-contenido p {
    margin: 0 0 10px 0;
}

.chatbot-mensaje-contenido p:last-child {
    margin-bottom: 0;
}

.chatbot-mensaje-contenido ul,
.chatbot-mensaje-contenido ol {
    margin: 10px 0;
    padding-left: 20px;
}

.chatbot-mensaje-contenido li {
    margin: 5px 0;
}

.chatbot-mensaje-contenido strong {
    font-weight: 600;
    color: var(--chatbot-primary);
}

/* Mensaje del usuario */
.chatbot-mensaje-usuario {
    flex-direction: row-reverse;
}

.chatbot-mensaje-usuario .chatbot-mensaje-avatar {
    background: var(--chatbot-primary);
    color: white;
}

.chatbot-mensaje-usuario .chatbot-mensaje-contenido {
    background: var(--chatbot-primary);
    color: white;
}

.chatbot-mensaje-usuario .chatbot-mensaje-contenido strong {
    color: white;
}

/* Mensaje de la IA */
.chatbot-mensaje-ia .chatbot-mensaje-avatar {
    background: linear-gradient(135deg, var(--chatbot-secondary), #059669);
    color: white;
}

/* Mensaje del sistema */
.chatbot-sistema .chatbot-mensaje-avatar {
    background: linear-gradient(135deg, var(--chatbot-warning), #ea580c);
    color: white;
}

.chatbot-sistema .chatbot-mensaje-contenido {
    background: #fef3c7;
    border-left: 4px solid var(--chatbot-warning);
}

/* Mensaje de error */
.chatbot-error .chatbot-mensaje-avatar {
    background: var(--chatbot-danger);
    color: white;
}

.chatbot-error .chatbot-mensaje-contenido {
    background: #fee2e2;
    border-left: 4px solid var(--chatbot-danger);
    color: #991b1b;
}

/* Metadata del mensaje */
.chatbot-mensaje-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 11px;
    opacity: 0.7;
}

.chatbot-mensaje-usuario .chatbot-mensaje-meta {
    border-top-color: rgba(255, 255, 255, 0.3);
}

.chatbot-mensaje-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   INDICADOR DE ESCRITURA (Typing)
   ============================================ */
.chatbot-typing {
    display: flex;
    gap: 12px;
    padding: 0 20px 20px 20px;
    background: var(--chatbot-bg-light);
}

.chatbot-typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-secondary), #059669);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chatbot-typing-dots {
    background: white;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    gap: 6px;
    align-items: center;
}

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

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

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

@keyframes chatbot-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   INPUT DE MENSAJE
   ============================================ */
.chatbot-input-container {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: white;
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    border: 2px solid var(--chatbot-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--chatbot-primary);
}

.chatbot-input::placeholder {
    color: var(--chatbot-text-light);
}

.chatbot-enviar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-enviar:hover {
    background: var(--chatbot-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.chatbot-enviar:active {
    transform: translateY(0);
}

.chatbot-enviar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   INFORMACIÓN DE USO
   ============================================ */
.chatbot-info {
    padding: 10px 15px;
    background: var(--chatbot-bg-light);
    border-top: 1px solid var(--chatbot-border);
    text-align: center;
    flex-shrink: 0;
}

.chatbot-info small {
    color: var(--chatbot-text-light);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chatbot-info i {
    color: var(--chatbot-primary);
}

/* ============================================
   RESPONSIVE - TABLETS
   ============================================ */
@media (max-width: 768px) {
    :root {
        --chatbot-panel-width: 100%;
    }
    
    .chatbot-panel {
        width: 100%;
    }
    
    .chatbot-toggle {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

/* ============================================
   RESPONSIVE - MÓVILES
   ============================================ */
@media (max-width: 480px) {
    .chatbot-header {
        padding: 15px;
    }
    
    .chatbot-header-info h3 {
        font-size: 16px;
    }
    
    .chatbot-header-info i {
        font-size: 24px;
    }
    
    .chatbot-acciones-rapidas {
        padding: 12px;
        gap: 6px;
    }
    
    .chatbot-accion-btn {
        padding: 10px 12px;
        min-width: 70px;
    }
    
    .chatbot-accion-btn i {
        font-size: 18px;
    }
    
    .chatbot-accion-btn span {
        font-size: 10px;
    }
    
    .chatbot-mensajes {
        padding: 15px;
    }
    
    .chatbot-mensaje-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .chatbot-mensaje-contenido {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .chatbot-input-container {
        padding: 12px;
    }
    
    .chatbot-toggle {
        bottom: 15px;
        right: 15px;
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
}

/* ============================================
   DARK MODE (Opcional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --chatbot-bg: #1f2937;
        --chatbot-bg-light: #111827;
        --chatbot-bg-dark: #0f172a;
        --chatbot-text: #f9fafb;
        --chatbot-text-light: #9ca3af;
        --chatbot-border: #374151;
    }
    
    .chatbot-mensaje-contenido {
        background: #374151;
        color: var(--chatbot-text);
    }
    
    .chatbot-typing-dots {
        background: #374151;
    }
    
    .chatbot-input {
        background: #374151;
        color: var(--chatbot-text);
        border-color: var(--chatbot-border);
    }
    
    .chatbot-accion-btn {
        background: #374151;
        color: var(--chatbot-text);
        border-color: var(--chatbot-border);
    }
}

/* ============================================
   ANIMACIONES ADICIONALES
   ============================================ */
@keyframes chatbot-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Aplicar animación al abrir panel */
.chatbot-panel-abierto {
    animation: chatbot-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   UTILIDADES
   ============================================ */
.chatbot-oculto {
    display: none !important;
}

.chatbot-invisible {
    opacity: 0;
    pointer-events: none;
}

/* Prevenir selección de texto en botones */
.chatbot-toggle,
.chatbot-close,
.chatbot-accion-btn,
.chatbot-enviar {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
