/* DESchat Widget Styles */

:root {
    --deschat-primary: #4F46E5;
    --deschat-secondary: #F3F4F6;
    --deschat-text-primary: #111827;
    --deschat-text-user: #FFFFFF;
    --deschat-bg: #FFFFFF;
}

/* Botón flotante */
#deschat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--deschat-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
}

#deschat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#deschat-button img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

#deschat-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Botón de información del producto */
#deschat-product-button {
    position: fixed;
    bottom: 20px;
    right: 90px; /* A la izquierda del botón principal */
    width: auto;
    min-width: 50px;
    height: 50px;
    padding: 0 16px;
    border-radius: 25px;
    background: var(--deschat-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 999999;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
    border: none;
    color: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}

#deschat-product-button.visible {
    opacity: 1;
    pointer-events: auto;
    animation: slideInLeft 0.3s ease-out;
}

#deschat-product-button.hiding {
    animation: mergeIntoWidget 0.5s ease-in-out forwards;
    pointer-events: none;
}

#deschat-product-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#deschat-product-button svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

@keyframes mergeIntoWidget {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    50% {
        opacity: 0.7;
        transform: translateX(35px) scale(0.8);
    }
    100% {
        opacity: 0;
        transform: translateX(70px) scale(0.3);
    }
}

/* Modal del chat */
#deschat-modal {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: var(--deschat-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 999998;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    transition: all 0.3s ease;
}

/* Modal maximizado */
#deschat-modal.maximized {
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    width: 80vw !important;
    height: 80vh !important;
    max-width: 1400px;
    max-height: 900px;
    border-radius: 16px;
}

#deschat-modal.active {
    display: flex;
}

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

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

#deschat-header-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#deschat-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#deschat-header-title {
    flex: 1;
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

#deschat-maximize,
#deschat-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#deschat-maximize:hover,
#deschat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

#deschat-maximize svg,
#deschat-close svg {
    width: 18px;
    height: 18px;
    stroke: white;
    stroke-width: 2;
}

/* Botón home - Simple */
#deschat-home {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

#deschat-home:hover {
    background: rgba(255, 255, 255, 0.3);
}

#deschat-home svg {
    width: 18px;
    height: 18px;
    stroke: white;
    stroke-width: 2;
    flex-shrink: 0;
}

/* Mensajes */
#deschat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #FAFAFA;
}

#deschat-messages::-webkit-scrollbar {
    width: 6px;
}

#deschat-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.deschat-message {
    display: flex;
    gap: 8px;
    max-width: 80%;
    animation: messageIn 0.2s ease-out;
}

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

.deschat-message.bot {
    align-self: flex-start;
}

.deschat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.deschat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--deschat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.deschat-message.bot .deschat-message-avatar {
    background: var(--deschat-secondary);
}

.deschat-message-avatar svg {
    width: 18px;
    height: 18px;
}

.deschat-message.bot .deschat-message-avatar svg {
    fill: var(--deschat-primary);
}

.deschat-message.user .deschat-message-avatar svg {
    fill: white;
}

.deschat-message-content {
    background: var(--deschat-secondary);
    padding: 10px 14px;
    border-radius: 12px;
    color: var(--deschat-text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.deschat-message-content a {
    color: var(--deschat-primary);
    text-decoration: underline;
    word-break: break-word;
}

.deschat-message-content strong {
    font-weight: 600;
    color: var(--deschat-text-primary);
}

.deschat-message-content a:hover {
    opacity: 0.8;
}

/* Imágenes inline en mensajes del bot (productos de pedidos, etc.) */
.deschat-inline-img {
    display: block;
    max-width: 80px;
    max-height: 80px;
    border-radius: 8px;
    margin: 6px 0;
    object-fit: cover;
    border: 1px solid #E5E7EB;
    background: white;
}

.deschat-message.user .deschat-message-content {
    background: var(--deschat-primary);
    color: var(--deschat-text-user);
}

.deschat-message.user .deschat-message-content a {
    color: white;
}

.deschat-message-time {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 4px;
}

/* Input */
#deschat-input-container {
    padding: 16px 20px;
    background: var(--deschat-bg);
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

#deschat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #D1D5DB;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#deschat-input:focus {
    border-color: var(--deschat-primary);
}

#deschat-send {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--deschat-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#deschat-send:hover {
    background: #4338CA;
}

#deschat-send:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
}

#deschat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Typing indicator */
.deschat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--deschat-secondary);
    border-radius: 12px;
    width: fit-content;
}

.deschat-typing span {
    width: 8px;
    height: 8px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Quick Replies */
.deschat-quick-replies {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
    animation: messageIn 0.3s ease-out;
    max-width: 100%;
}

.deschat-quick-reply-button {
    background: white;
    border: 2px solid var(--deschat-primary);
    color: var(--deschat-primary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.deschat-quick-reply-button:hover {
    background: var(--deschat-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.deschat-quick-reply-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Quick replies en modal maximizado - 40% ancho */
#deschat-modal.maximized .deschat-quick-reply-button {
    width: 40%;
    margin: 0 auto;
}

@keyframes messageOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Responsive mobile */
@media (max-width: 768px) {
    #deschat-modal {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    #deschat-button {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
    }
    
    #deschat-product-button {
        bottom: 15px;
        right: 80px;
        font-size: 0; /* Ocultar texto en móvil */
        min-width: 50px;
        height: 50px;
        padding: 0 12px;
    }
    
    #deschat-product-button svg {
        width: 24px;
        height: 24px;
    }
    
    .deschat-quick-reply-button {
        font-size: 12px;
        padding: 7px 10px;
    }
}
