/**
 * LUXUTI Chat Widget Styles
 * Compatible con PrestaShop 8.2
 */

:root {
    --luxchat-black: #0a0a0b;
    --luxchat-dark: #111113;
    --luxchat-gray-900: #18181b;
    --luxchat-gray-800: #27272a;
    --luxchat-gray-700: #3f3f46;
    --luxchat-gray-600: #52525b;
    --luxchat-gray-500: #71717a;
    --luxchat-gray-400: #a1a1aa;
    --luxchat-gray-300: #d4d4d8;
    --luxchat-white: #fafafa;
    --luxchat-accent: #c9a227;
    --luxchat-accent-light: #e3c565;
    --luxchat-accent-glow: rgba(201, 162, 39, 0.15);
}

/* Chat Button */
.luxchat-button {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: auto;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--luxchat-accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(201, 162, 39, 0.4);
    z-index: 99999;
    transition: all 0.3s ease;
    padding: 0;
    outline: none;
}

.luxchat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(201, 162, 39, 0.5);
}

.luxchat-button:focus {
    outline: 2px solid var(--luxchat-accent-light);
    outline-offset: 2px;
}

.luxchat-button-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--luxchat-accent);
    animation: luxchat-pulse 2s infinite;
    pointer-events: none;
}

@keyframes luxchat-pulse {
    0% { 
        transform: scale(1); 
        opacity: 1; 
    }
    100% { 
        transform: scale(1.5); 
        opacity: 0; 
    }
}

.luxchat-button.open .luxchat-button-pulse {
    display: none;
}

.luxchat-button svg {
    width: 24px;
    height: 24px;
    stroke: var(--luxchat-black);
    stroke-width: 2;
    fill: none;
    position: relative;
    z-index: 1;
}

.luxchat-button .luxchat-icon-close {
    display: none;
}

.luxchat-button.open .luxchat-icon-chat {
    display: none;
}

.luxchat-button.open .luxchat-icon-close {
    display: block;
}

/* Chat Window */
.luxchat-window {
    position: fixed;
    bottom: 100px;
    left: 24px;
    right: auto;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 150px);
    background: var(--luxchat-dark);
    border-radius: 20px;
    border: 1px solid var(--luxchat-gray-800);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    animation: luxchat-fadeIn 0.3s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.luxchat-window.open {
    display: flex;
}

@keyframes luxchat-fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* Chat Header */
.luxchat-header {
    padding: 1.25rem;
    background: var(--luxchat-gray-900);
    border-bottom: 1px solid var(--luxchat-gray-800);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.luxchat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--luxchat-accent), var(--luxchat-accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.luxchat-avatar svg {
    width: 20px;
    height: 20px;
    stroke: var(--luxchat-black);
    stroke-width: 2;
    fill: none;
}

.luxchat-header-info {
    flex: 1;
    min-width: 0;
}

.luxchat-header-title {
    font-family: 'Syne', 'Inter', sans-serif;
    font-weight: 600;
    color: var(--luxchat-white);
    font-size: 1rem;
    margin: 0 0 0.125rem 0;
    line-height: 1.2;
}

.luxchat-header-status {
    font-size: 0.75rem;
    color: var(--luxchat-gray-500);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0;
}

.luxchat-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Close button in header */
.luxchat-close-btn {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
    padding: 0;
}

.luxchat-close-btn svg {
    width: 18px;
    height: 18px;
    stroke: var(--luxchat-gray-400);
    stroke-width: 2;
    fill: none;
}

.luxchat-close-btn:hover {
    background: var(--luxchat-gray-800);
}

.luxchat-close-btn:hover svg {
    stroke: var(--luxchat-white);
}

.luxchat-close-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--luxchat-accent-glow);
}

@media (max-width: 480px) {
    .luxchat-close-btn {
        display: flex;
    }
}

/* Messages Container */
.luxchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.luxchat-messages::-webkit-scrollbar-track {
    background: var(--luxchat-gray-900);
}

.luxchat-messages::-webkit-scrollbar-thumb {
    background: var(--luxchat-gray-700);
    border-radius: 3px;
}

.luxchat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--luxchat-gray-600);
}

/* Message Bubbles */
.luxchat-message {
    display: flex;
    animation: luxchat-messageFadeIn 0.3s ease;
}

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

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

.luxchat-message.assistant {
    justify-content: flex-start;
}

.luxchat-bubble {
    max-width: 85%;
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.luxchat-message.user .luxchat-bubble {
    background: var(--luxchat-accent);
    color: var(--luxchat-black);
    border-radius: 16px 16px 4px 16px;
}

.luxchat-message.assistant .luxchat-bubble {
    background: var(--luxchat-gray-800);
    color: var(--luxchat-gray-300);
    border-radius: 16px 16px 16px 4px;
}

/* Text formatting inside bubbles */
.luxchat-bubble p {
    margin: 0 0 0.75em 0;
}

.luxchat-bubble p:last-child {
    margin-bottom: 0;
}

.luxchat-bubble strong {
    color: var(--luxchat-white);
    font-weight: 600;
}

.luxchat-bubble em {
    font-style: italic;
}

.luxchat-message.user .luxchat-bubble strong {
    color: var(--luxchat-black);
}

/* Links inside bubbles */
.luxchat-link {
    color: var(--luxchat-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.luxchat-link:hover {
    border-bottom-color: var(--luxchat-accent);
}

.luxchat-whatsapp::before {
    content: '📱 ';
}

.luxchat-email::before {
    content: '✉️ ';
}

/* Typing Indicator */
.luxchat-typing {
    display: flex;
    gap: 4px;
    padding: 1rem;
    background: var(--luxchat-gray-800);
    border-radius: 16px 16px 16px 4px;
    width: fit-content;
}

.luxchat-typing span {
    width: 8px;
    height: 8px;
    background: var(--luxchat-gray-500);
    border-radius: 50%;
    animation: luxchat-typing 1.4s infinite;
}

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

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

@keyframes luxchat-typing {
    0%, 60%, 100% { 
        transform: translateY(0); 
    }
    30% { 
        transform: translateY(-8px); 
    }
}

/* Quick Questions */
.luxchat-quick {
    padding: 0 1rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex-shrink: 0;
}

.luxchat-quick-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--luxchat-gray-900);
    border: 1px solid var(--luxchat-gray-700);
    border-radius: 100px;
    color: var(--luxchat-gray-400);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.luxchat-quick-btn:hover {
    border-color: var(--luxchat-accent);
    color: var(--luxchat-accent);
    background: var(--luxchat-accent-glow);
}

.luxchat-quick-btn:focus {
    outline: none;
    border-color: var(--luxchat-accent);
    box-shadow: 0 0 0 2px var(--luxchat-accent-glow);
}

/* Input Area */
.luxchat-input-area {
    padding: 1rem;
    background: var(--luxchat-gray-900);
    border-top: 1px solid var(--luxchat-gray-800);
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.luxchat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--luxchat-white);
    background: var(--luxchat-gray-800);
    border: 1px solid var(--luxchat-gray-700);
    border-radius: 100px;
    outline: none;
    transition: all 0.2s ease;
    min-width: 0;
}

.luxchat-input::placeholder {
    color: var(--luxchat-gray-600);
}

.luxchat-input:focus {
    border-color: var(--luxchat-accent);
    box-shadow: 0 0 0 2px var(--luxchat-accent-glow);
}

.luxchat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--luxchat-gray-700);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.luxchat-send svg {
    width: 20px;
    height: 20px;
    stroke: var(--luxchat-gray-500);
    stroke-width: 2;
    fill: none;
    transition: stroke 0.2s ease;
}

.luxchat-send.active {
    background: var(--luxchat-accent);
}

.luxchat-send.active svg {
    stroke: var(--luxchat-black);
}

.luxchat-send:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.luxchat-send:not(:disabled):hover {
    transform: scale(1.05);
}

.luxchat-send:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--luxchat-accent-glow);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .luxchat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        max-width: 100%;
        /* Usar dvh (dynamic viewport height) si está disponible */
        height: 100dvh;
        max-height: 100dvh;
        /* Fallback para navegadores antiguos */
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .luxchat-button {
        bottom: 20px;
        left: 16px;
        width: 52px;
        height: 52px;
    }

    /* Ocultar botón flotante cuando el chat está abierto */
    .luxchat-button.open {
        display: none;
    }

    .luxchat-close-btn {
        display: flex;
    }

    /* Ajustar header para tener más espacio arriba */
    .luxchat-header {
        padding-top: 1.75rem;
        padding-bottom: 1.5rem;
        min-height: 80px;
    }

    .luxchat-quick {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .luxchat-quick::-webkit-scrollbar {
        display: none;
    }

    /* Asegurar que el input area sea visible */
    .luxchat-input-area {
        padding: 1rem;
        padding-bottom: 1.5rem;
    }

    /* Mejorar el área de mensajes en móvil */
    .luxchat-messages {
        padding-bottom: 1rem;
    }

    /* Ajuste para Chrome móvil cuando la barra de direcciones está visible */
    @supports (-webkit-touch-callout: none) {
        .luxchat-window {
            /* iOS Safari */
            height: -webkit-fill-available;
            max-height: -webkit-fill-available;
        }
    }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .luxchat-button-pulse {
        animation: none;
    }

    .luxchat-window {
        animation: none;
    }

    .luxchat-message {
        animation: none;
    }

    .luxchat-typing span {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .luxchat-window {
        border-width: 2px;
    }

    .luxchat-bubble {
        border: 1px solid currentColor;
    }

    .luxchat-input {
        border-width: 2px;
    }
}
