/**
 * Wizor Chat - Estilos del Widget
 */

/* Importar fuente Montserrat */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* === Container Principal === */
#wizor-chat-container {
    position: fixed;
    z-index: 999999;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

#wizor-chat-container * {
    box-sizing: border-box;
}

/* Posiciones */
#wizor-chat-container.wizor-chat-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

#wizor-chat-container.wizor-chat-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* === Botón Toggle === */
.wizor-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #71CC98;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    padding: 0;
}

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

.wizor-chat-toggle img,
.wizor-chat-toggle svg {
    transition: opacity 0.3s ease;
}

.wizor-chat-icon-open {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wizor-chat-close-icon {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.wizor-chat-toggle.active .wizor-chat-icon-open {
    opacity: 0;
}

.wizor-chat-toggle.active .wizor-chat-close-icon {
    opacity: 1;
}

/* === Ventana del Chat === */
.wizor-chat-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.wizor-chat-position-bottom-right .wizor-chat-window {
    right: 0;
}

.wizor-chat-position-bottom-left .wizor-chat-window {
    left: 0;
}

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

/* === Header === */
.wizor-chat-header {
    background: #0050A3;
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wizor-chat-header h3 {
    margin: 0 0 5px 0 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    color: white !important;
}

.wizor-chat-header p {
    margin: 0 !important;
    font-size: 13px !important;
    opacity: 0.9 !important;
    line-height: 1.4 !important;
    color: white !important;
}

/* Botón de cerrar en header (solo visible en mobile) */
.wizor-chat-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

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

.wizor-chat-close-btn svg {
    display: block;
    width: 24px;
    height: 24px;
}

/* === Mensajes === */
.wizor-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

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

.wizor-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.wizor-chat-message {
    display: flex;
    animation: messageSlideIn 0.3s ease;
}

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

.wizor-chat-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.wizor-chat-message-content p {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

/* Mensajes del bot */
.wizor-chat-message-bot {
    justify-content: flex-start;
}

.wizor-chat-message-bot .wizor-chat-message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Mensajes del usuario */
.wizor-chat-message-user {
    justify-content: flex-end;
}

.wizor-chat-message-user .wizor-chat-message-content {
    background: #0050A3;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Estado de "escribiendo..." */
.wizor-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wizor-chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.wizor-chat-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.wizor-chat-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* === Input Container === */
.wizor-chat-input-container {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 16px;
}

#wizor-chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.wizor-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 120px;
    overflow-y: auto;
}

.wizor-chat-input:focus {
    border-color: #71CC98;
}

.wizor-chat-input::-webkit-scrollbar {
    width: 4px;
}

.wizor-chat-input::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.wizor-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #71CC98;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.wizor-chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(113, 204, 152, 0.3);
}

.wizor-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wizor-chat-send-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.wizor-chat-footer {
    margin-top: 8px !important;
    text-align: center !important;
}

.wizor-chat-footer small {
    font-size: 11px !important;
    color: #a0aec0 !important;
    line-height: 1.4 !important;
}

.wizor-chat-footer strong,
.wizor-chat-footer span {
    font-weight: bold !important;
}

/* === Chat Inline (Shortcode) === */
.wizor-chat-inline {
    max-width: 600px;
    margin: 20px auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.wizor-chat-messages-inline {
    padding: 20px;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    background: #f7f8fa;
}

.wizor-chat-form-inline {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.wizor-chat-form-inline input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

.wizor-chat-form-inline input:focus {
    border-color: var(--wizor-theme-color, #0073aa);
}

.wizor-chat-form-inline button {
    padding: 10px 24px;
    background: var(--wizor-theme-color, #0073aa);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wizor-chat-form-inline button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
}

/* === Responsive === */
@media (max-width: 480px) {
    /* Botón toggle en mobile - mantener en esquina */
    #wizor-chat-container.wizor-chat-position-bottom-right {
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
    }
    
    #wizor-chat-container.wizor-chat-position-bottom-left {
        bottom: 10px !important;
        left: 10px !important;
        right: auto !important;
    }
    
    /* Chat fullscreen en mobile (como otros chatbots) */
    .wizor-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height para mobile */
        max-width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    
    /* Header ajustado para mobile */
    .wizor-chat-header {
        border-radius: 0 !important;
        flex-shrink: 0;
        padding: 16px !important;
    }
    
    /* Área de mensajes: ocupa el espacio disponible */
    .wizor-chat-messages {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 16px !important;
    }
    
    /* Input container fijo en la parte inferior */
    .wizor-chat-input-container {
        flex-shrink: 0;
        padding: 12px !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important; /* Respeta notch/home indicator */
    }
    
    /* Footer más compacto en mobile */
    .wizor-chat-footer {
        margin-top: 6px !important;
    }
    
    .wizor-chat-footer small {
        font-size: 10px !important;
    }
    
    /* Input con mejor tamaño en mobile */
    .wizor-chat-input {
        font-size: 16px !important; /* Evita zoom automático en iOS */
        max-height: 100px !important;
    }
    
    /* Ocultar el botón cuando el chat está abierto en mobile */
    #wizor-chat-container.wizor-chat-open .wizor-chat-toggle {
        display: none;
    }
    
    /* Ajustar tamaño del botón toggle */
    .wizor-chat-toggle {
        width: 56px;
        height: 56px;
    }
    
    /* Mostrar botón de cerrar solo en mobile */
    .wizor-chat-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* === Error States === */
.wizor-chat-error {
    background: #fed7d7;
    color: #c53030;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin: 10px 20px;
    text-align: center;
}

/* === Loading State === */
.wizor-chat-loading {
    text-align: center;
    padding: 20px;
    color: #718096;
}
