/**
 * WP Ollama Chatbot - Estilos CSS
 *
 * @package WP_Ollama_Chatbot
 */

/* ========================================
   Contenedor Principal
   ======================================== */
#ollama-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#ollama-chatbot-container * {
    box-sizing: border-box;
}

/* Posicionamiento */
#ollama-chatbot-container.ollama-chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

#ollama-chatbot-container.ollama-chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* ========================================
   Botón Flotante
   ======================================== */
#ollama-chatbot-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background-color: #0073aa;
    color: white;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

#ollama-chatbot-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.15);
}

#ollama-chatbot-button:active {
    transform: translateY(0);
}

#ollama-chatbot-button svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

#ollama-chatbot-button span {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
}

/* ========================================
   Ventana del Chat
   ======================================== */
#ollama-chatbot-window {
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18), 0 6px 16px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatWindowSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ========================================
   Header
   ======================================== */
#ollama-chatbot-header {
    background-color: #0073aa;
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ollama-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ollama-header-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ollama-header-icon svg {
    width: 28px;
    height: 28px;
}

#ollama-chatbot-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.2;
}

#ollama-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#ollama-chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

#ollama-chatbot-close:active {
    background-color: rgba(255, 255, 255, 0.25);
}

/* ========================================
   Área de Mensajes
   ======================================== */
#ollama-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.ollama-message {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    animation: messageSlideIn 0.3s ease;
}

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

/* Avatar del bot */
.ollama-message-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.ollama-message-avatar svg {
    width: 22px;
    height: 22px;
}

/* Burbuja de mensaje */
.ollama-message-bubble {
    max-width: 75%;
}

.ollama-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

/* Mensajes del bot */
.ollama-bot-message .ollama-message-content {
    background-color: #e9ecef;
    color: #2c3e50;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 4px;
}

.ollama-bot-message .ollama-message-content a {
    color: #0073aa;
    text-decoration: underline;
}

.ollama-bot-message .ollama-message-content a:hover {
    color: #005177;
}

/* Mensajes del usuario */
.ollama-user-message {
    flex-direction: row-reverse;
}

.ollama-user-message .ollama-message-bubble {
    text-align: right;
}

.ollama-user-message .ollama-message-content {
    background-color: #0073aa;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Hora del mensaje */
.ollama-message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 6px;
    padding: 0 6px;
}

.ollama-user-message .ollama-message-time {
    text-align: right;
}

/* Mensajes de error */
.ollama-error-message .ollama-message-content {
    background-color: #fee;
    border-color: #fcc;
    color: #c33;
}

/* ========================================
   Indicador de Escritura
   ======================================== */
#ollama-chatbot-typing {
    display: flex;
    gap: 10px;
    padding: 0 20px 12px;
    background: #f8f9fa;
}

.ollama-typing-bubble {
    padding: 12px 16px;
    background-color: #e9ecef;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.ollama-typing-bubble span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6c757d;
    animation: typingDot 1.4s infinite;
}

.ollama-typing-bubble span:nth-child(1) {
    animation-delay: 0s;
}

.ollama-typing-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.ollama-typing-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ========================================
   Área de Input
   ======================================== */
#ollama-chatbot-input-area {
    display: flex;
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
    align-items: center;
}

#ollama-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    background: #f8f9fa;
}

#ollama-chatbot-input:focus {
    border-color: #0073aa;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

#ollama-chatbot-input::placeholder {
    color: #adb5bd;
}

#ollama-chatbot-send {
    width: 48px;
    height: 48px;
    background-color: #0073aa;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#ollama-chatbot-send:hover:not(:disabled) {
    background-color: #005a87;
    transform: scale(1.05);
}

#ollama-chatbot-send:active:not(:disabled) {
    transform: scale(0.95);
}

#ollama-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#ollama-chatbot-send svg {
    width: 22px;
    height: 22px;
}

/* ========================================
   Scrollbar Personalizada
   ======================================== */
#ollama-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

#ollama-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 480px) {
    #ollama-chatbot-window {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }

    #ollama-chatbot-container.ollama-chatbot-bottom-right,
    #ollama-chatbot-container.ollama-chatbot-bottom-left {
        bottom: 15px;
        right: 15px;
        left: auto;
    }

    #ollama-chatbot-button span {
        display: none;
    }

    #ollama-chatbot-button {
        width: 56px;
        height: 56px;
        padding: 0;
        justify-content: center;
    }

    .ollama-message-bubble {
        max-width: 85%;
    }
}

@media (max-width: 360px) {
    #ollama-chatbot-messages {
        padding: 15px;
    }

    #ollama-chatbot-input-area {
        padding: 12px;
    }

    .ollama-message-content {
        font-size: 13px;
    }
}

/* ========================================
   Animaciones y Efectos
   ======================================== */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Efecto de pulso para el botón cuando hay nuevo mensaje */
#ollama-chatbot-button.has-notification {
    animation: pulse 2s infinite;
}

/* ========================================
   Accesibilidad
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para navegación por teclado */
#ollama-chatbot-send:focus-visible,
#ollama-chatbot-close:focus-visible,
#ollama-chatbot-input:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ========================================
   Dark Mode Support (opcional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    #ollama-chatbot-window {
        background: #1e1e1e;
        color: #e0e0e0;
    }

    #ollama-chatbot-messages {
        background: #2d2d2d;
    }

    .ollama-bot-message .ollama-message-content {
        background-color: #3a3a3a;
        color: #e0e0e0;
        border-color: #4a4a4a;
    }

    #ollama-chatbot-input {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #4a4a4a;
    }

    #ollama-chatbot-input:focus {
        background: #2d2d2d;
        border-color: #0073aa;
    }

    #ollama-chatbot-input::placeholder {
        color: #757575;
    }

    #ollama-chatbot-input-area {
        background: #1e1e1e;
        border-top-color: #3a3a3a;
    }

    .ollama-message-time {
        color: #9e9e9e;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    #ollama-chatbot-container {
        display: none !important;
    }
}
