/* ============================================
   SOYAVE CHAT WIDGET
   Chat flotante para búsqueda de productos
   ============================================ */

:root {
    --soyave-chat-primary: #25D366;
    --soyave-chat-primary-dark: #1da851;
    --soyave-chat-bg: #f0f2f5;
    --soyave-chat-white: #ffffff;
    --soyave-chat-text: #1a1a2e;
    --soyave-chat-text-light: #667781;
    --soyave-chat-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    --soyave-chat-radius: 16px;
}

/* Botón flotante */
#soyave-chat-toggle {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--soyave-chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--soyave-chat-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.2s ease;
    padding: 0;
}

#soyave-chat-toggle.position-right {
    right: 24px;
}

#soyave-chat-toggle.position-left {
    left: 24px;
}

#soyave-chat-toggle:hover {
    transform: scale(1.1);
    background: var(--soyave-chat-primary-dark);
}

#soyave-chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: opacity 0.2s ease;
}

#soyave-chat-toggle .icon-close {
    display: none;
}

#soyave-chat-toggle.active .icon-chat {
    display: none;
}

#soyave-chat-toggle.active .icon-close {
    display: block;
}

/* Badge de notificación */
#soyave-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4444;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
}

/* Ventana del chat */
#soyave-chat-window {
    position: fixed;
    bottom: 100px;
    z-index: 99998;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: var(--soyave-chat-white);
    border-radius: var(--soyave-chat-radius);
    box-shadow: var(--soyave-chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#soyave-chat-window.position-right {
    right: 24px;
}

#soyave-chat-window.position-left {
    left: 24px;
}

#soyave-chat-window.open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Header del chat */
.soyave-chat-header {
    background: var(--soyave-chat-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.soyave-chat-header-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

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

.soyave-chat-header-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.soyave-chat-header-status {
    font-size: 12px;
    opacity: 0.85;
}

/* Botón nueva conversación en header */
.soyave-chat-new-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
    margin-left: auto;
}

.soyave-chat-new-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Picker/form desactivados */
.soyave-quote-picker.soyave-picker-used {
    opacity: 0.5;
    pointer-events: none;
}

.soyave-quote-form.soyave-form-used {
    opacity: 0.5;
    pointer-events: none;
}

/* Área de mensajes */
.soyave-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--soyave-chat-bg);
    scroll-behavior: smooth;
}

.soyave-chat-messages::-webkit-scrollbar {
    width: 5px;
}

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

.soyave-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* Mensajes */
.soyave-msg {
    max-width: 85%;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: soyaveMsgIn 0.3s ease;
}

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

.soyave-msg-bot {
    background: var(--soyave-chat-white);
    color: var(--soyave-chat-text);
    border-bottom-left-radius: 4px;
    margin-right: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.soyave-msg-user {
    background: var(--soyave-chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.soyave-msg-bot a {
    color: var(--soyave-chat-primary);
    text-decoration: underline;
}

.soyave-msg-bot b, .soyave-msg-bot strong {
    font-weight: 600;
}

/* Typing indicator */
.soyave-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--soyave-chat-white);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.soyave-typing-dot {
    width: 8px;
    height: 8px;
    background: #bbb;
    border-radius: 50%;
    animation: soyaveTyping 1.4s infinite;
}

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

@keyframes soyaveTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Tarjetas de producto inline (dentro del mensaje) */
.soyave-inline-product-wrap {
    position: relative;
    margin: 10px 0;
}

.soyave-inline-product {
    display: flex;
    gap: 10px;
    background: #f8f9fa;
    border: 1px solid #e4e6ea;
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.soyave-inline-product-wrap .soyave-inline-product {
    border-radius: 10px 10px 0 0;
    border-bottom: none;
}

.soyave-inline-product:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    border-color: var(--soyave-chat-primary);
}

.soyave-inline-product-img {
    width: 90px;
    min-height: 90px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background: #eee;
}

.soyave-inline-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.soyave-inline-product-noimg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: #f0f0f0;
}

.soyave-inline-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: #ff4444;
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.3px;
}

.soyave-inline-product-detail {
    flex: 1;
    padding: 8px 10px 8px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.soyave-inline-product-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--soyave-chat-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 3px;
}

.soyave-inline-product-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--soyave-chat-primary-dark);
    margin-bottom: 2px;
}

.soyave-inline-product-colors {
    font-size: 11px;
    color: var(--soyave-chat-text-light);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.soyave-inline-product-link {
    font-size: 11px;
    color: var(--soyave-chat-primary);
    font-weight: 500;
}

/* Bot message adjustments for inline products */
.soyave-msg-bot {
    max-width: 92%;
}

.soyave-msg-bot .soyave-inline-product:last-child {
    margin-bottom: 0;
}

/* Legacy carousel kept for backwards compat */
.soyave-products-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 8px 0 12px 0;
    margin-top: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.soyave-products-carousel::-webkit-scrollbar {
    height: 4px;
}

.soyave-products-carousel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.soyave-product-card {
    min-width: 140px;
    max-width: 160px;
    background: var(--soyave-chat-white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    scroll-snap-align: start;
    transition: transform 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.soyave-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.soyave-product-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.soyave-product-card-info {
    padding: 8px 10px;
}

.soyave-product-card-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--soyave-chat-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.soyave-product-card-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--soyave-chat-primary-dark);
}

.soyave-product-card-sale {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #ff4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Input area */
.soyave-chat-input-area {
    padding: 12px 16px;
    background: var(--soyave-chat-white);
    border-top: 1px solid #e8e8e8;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.soyave-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    line-height: 2;
}

.soyave-chat-input:focus {
    border-color: var(--soyave-chat-primary);
}

.soyave-chat-input::placeholder {
    color: #999;
}

.soyave-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--soyave-chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
    padding: 0;
}

.soyave-chat-send:hover {
    background: var(--soyave-chat-primary-dark);
}

.soyave-chat-send:active {
    transform: scale(0.95);
}

.soyave-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

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

/* Powered by */
.soyave-chat-powered {
    text-align: center;
    font-size: 10px;
    color: #999;
    padding: 4px;
    background: var(--soyave-chat-white);
}

/* Responsive */
@media (max-width: 480px) {
    #soyave-chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        bottom: 90px;
        right: 8px !important;
        left: 8px !important;
        border-radius: 12px;
    }
    
    #soyave-chat-toggle {
        bottom: 16px;
        right: 16px !important;
        width: 54px;
        height: 54px;
    }

    .soyave-product-card {
        min-width: 120px;
    }

    .soyave-inline-product-img {
        width: 75px;
        min-height: 75px;
    }

    .soyave-inline-product-name {
        font-size: 12px;
    }

    .soyave-inline-product-price {
        font-size: 12px;
    }

    .soyave-msg-bot {
        max-width: 95%;
    }
}

/* Quick suggestions */
.soyave-quick-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.soyave-quick-btn {
    background: var(--soyave-chat-white);
    border: 1px solid var(--soyave-chat-primary);
    color: var(--soyave-chat-primary);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.soyave-quick-btn:hover {
    background: var(--soyave-chat-primary);
    color: white;
}

/* ============================================
   BOTÓN COTIZAR EN TARJETA DE PRODUCTO
   ============================================ */

.soyave-quote-add-btn {
    display: block;
    width: 100%;
    padding: 7px 10px;
    background: var(--soyave-chat-primary);
    color: white;
    border: 1px solid #e4e6ea;
    border-top: none;
    border-radius: 0 0 10px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.soyave-quote-add-btn:hover {
    background: var(--soyave-chat-primary-dark);
}

/* ============================================
   SELECTOR DE CANTIDAD Y COLOR
   ============================================ */

.soyave-quote-picker {
    background: #f8f9fa;
    border: 1px solid #e4e6ea;
    border-radius: 10px;
    padding: 14px;
    margin-top: 4px;
}

.soyave-quote-field {
    margin-bottom: 12px;
}

.soyave-quote-field:last-of-type {
    margin-bottom: 14px;
}

.soyave-quote-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--soyave-chat-text);
    margin-bottom: 6px;
}

/* Control de cantidad */
.soyave-qty-control {
    display: flex;
    align-items: center;
    gap: 0;
    width: fit-content;
}

.soyave-qty-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #ddd;
    background: white;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    color: var(--soyave-chat-text);
}

.soyave-qty-btn:hover {
    background: #f0f0f0;
}

.soyave-qty-minus {
    border-radius: 6px 0 0 6px;
}

.soyave-qty-plus {
    border-radius: 0 6px 6px 0;
}

.soyave-qty-input {
    width: 56px;
    height: 34px;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    -moz-appearance: textfield;
    outline: none;
}

.soyave-qty-input::-webkit-outer-spin-button,
.soyave-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Opciones de color */
.soyave-color-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.soyave-color-option {
    padding: 5px 12px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--soyave-chat-text);
}

.soyave-color-option:hover {
    border-color: var(--soyave-chat-primary);
}

.soyave-color-option.selected {
    background: var(--soyave-chat-primary);
    border-color: var(--soyave-chat-primary);
    color: white;
    font-weight: 600;
}

/* Botón confirmar */
.soyave-confirm-add-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--soyave-chat-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.soyave-confirm-add-btn:hover {
    background: var(--soyave-chat-primary-dark);
}

.soyave-confirm-add-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   CARRITO DE COTIZACIÓN
   ============================================ */

.soyave-quote-cart {
    background: #f8f9fa;
    border: 1px solid #e4e6ea;
    border-radius: 10px;
    overflow: hidden;
}

.soyave-cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.soyave-cart-item:last-child {
    border-bottom: none;
}

.soyave-cart-item-info {
    flex: 1;
    min-width: 0;
}

.soyave-cart-item-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--soyave-chat-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.soyave-cart-color {
    font-size: 11px;
    color: var(--soyave-chat-text-light);
}

.soyave-cart-item-qty {
    display: block;
    font-size: 12px;
    color: var(--soyave-chat-text-light);
    margin-top: 2px;
}

.soyave-cart-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #cc4444;
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.soyave-cart-remove:hover {
    background: #fee;
}

.soyave-cart-total {
    text-align: right;
    font-size: 13px;
    color: var(--soyave-chat-text);
    padding: 8px 0 4px;
}

/* ============================================
   FORMULARIO DE DATOS DEL CLIENTE
   ============================================ */

.soyave-quote-form {
    background: #f8f9fa;
    border: 1px solid #e4e6ea;
    border-radius: 10px;
    padding: 14px;
    margin-top: 4px;
}

.soyave-form-field {
    margin-bottom: 10px;
}

.soyave-form-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--soyave-chat-text);
    margin-bottom: 4px;
}

.soyave-form-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    background: white;
}

.soyave-form-input:focus {
    border-color: var(--soyave-chat-primary);
}

.soyave-form-textarea {
    resize: vertical;
    min-height: 40px;
}

.soyave-quote-submit-btn {
    display: block;
    width: 100%;
    padding: 11px;
    margin-top: 12px;
    background: var(--soyave-chat-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.soyave-quote-submit-btn:hover {
    background: var(--soyave-chat-primary-dark);
}

.soyave-quote-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
