/* ========================================
   CHATBOT IA - ESTILOS FRONTEND (WIDGET)
   ======================================== */

:root {
    --chatbot-primary: #6c1aad;
    --chatbot-secondary: #8b4bb1;
    --chatbot-success: #27ae60;
    --chatbot-danger: #e74c3c;
    --chatbot-light: #f5f5f5;
    --chatbot-dark: #2c3e50;
    --chatbot-border: #ddd;
    --chatbot-text: #333;
}

/* Widget Flotante Principal */
.chatbot-floating-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    z-index: 999;
}

/* Botón Toggle */
.chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

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

/* Badge de notificación */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--chatbot-danger);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Contenedor del Chat */
.chatbot-container {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    height: 600px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
    overflow: hidden;
}

.chatbot-container.hidden {
    display: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header del Chat */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.chatbot-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

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

.chatbot-header-text .chatbot-status {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.chatbot-close-btn:hover {
    transform: rotate(90deg);
}

/* Área de Mensajes */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #fafafa;
    scroll-behavior: smooth;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Mensajes Individuales */
.chatbot-message {
    margin-bottom: 12px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user-message {
    justify-content: flex-end;
}

.chatbot-message.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-content {
    background-color: var(--chatbot-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background-color: white;
    color: var(--chatbot-text);
    border: 1px solid var(--chatbot-border);
    border-bottom-left-radius: 4px;
}

.message-time {
    display: block;
    font-size: 12px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

/* Mensaje de Bienvenida */
.welcome-message .message-content {
    background-color: #f0f0f0;
    font-size: 15px;
}

.welcome-message .message-content p {
    margin: 4px 0;
}

/* Indicador de Escritura */
.typing-indicator .message-content {
    padding: 12px;
}

.typing-indicator .dot {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: #999;
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Área de Input */
.chatbot-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    background-color: white;
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(108, 26, 173, 0.1);
}

.chatbot-input::placeholder {
    color: #999;
}

.chatbot-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--chatbot-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 16px;
}

.chatbot-send-btn:hover {
    background-color: var(--chatbot-secondary);
    transform: scale(1.05);
}

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

.chatbot-send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Footer */
.chatbot-footer {
    padding: 8px 12px;
    background-color: #f9f9f9;
    border-top: 1px solid var(--chatbot-border);
    text-align: center;
}

.chatbot-footer a {
    color: var(--chatbot-primary);
    text-decoration: none;
    font-size: 12px;
    margin: 0 4px;
}

.chatbot-footer a:hover {
    text-decoration: underline;
}

/* Modales */
.chatbot-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.chatbot-modal.hidden {
    display: none;
}

.chatbot-modal-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chatbot-modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--chatbot-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-modal-header h3 {
    margin: 0;
    color: var(--chatbot-primary);
    font-size: 18px;
}

.chatbot-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
}

.chatbot-modal-body {
    padding: 20px;
}

.chatbot-modal-footer {
    padding: 16px;
    border-top: 1px solid var(--chatbot-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Formularios en Modal */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--chatbot-dark);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--chatbot-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-control:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(108, 26, 173, 0.1);
}

/* Rating Estrellas */
.rating-stars {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
}

.rating-stars .star {
    background: none;
    border: none;
    font-size: 40px;
    cursor: pointer;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.rating-stars .star:hover {
    transform: scale(1.2);
    opacity: 1;
}

.rating-stars .star.selected {
    opacity: 1;
}

/* Botones */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--chatbot-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--chatbot-secondary);
}

.btn-secondary {
    background-color: #e0e0e0;
    color: var(--chatbot-dark);
}

.btn-secondary:hover {
    background-color: #d0d0d0;
}

/* Utilidades */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-3 {
    margin-top: 16px;
}

/* Responsive Design */
@media (max-width: 480px) {
    .chatbot-floating-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .chatbot-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        max-height: 500px;
    }
    
    .chatbot-message-content {
        max-width: 85%;
    }
    
    .chatbot-modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 768px) {
    .chatbot-container {
        width: 320px;
        height: 500px;
    }
}

/* Dark Mode (opcional) */
@media (prefers-color-scheme: dark) {
    .chatbot-container {
        background-color: #2c2c2c;
        color: #fff;
    }
    
    .chatbot-messages {
        background-color: #1e1e1e;
    }
    
    .message-content {
        color: #fff;
    }
    
    .bot-message .message-content {
        background-color: #3a3a3a;
        color: #fff;
        border-color: #555;
    }
    
    .chatbot-input-area {
        background-color: #2c2c2c;
        border-color: #444;
    }
    
    .chatbot-input {
        background-color: #3a3a3a;
        color: #fff;
        border-color: #555;
    }
    
    .chatbot-input::placeholder {
        color: #999;
    }
}
