/* ==========================================
 * ESTILOS DEL CHATBOT (CSS) - CUSTOM TEMPLATE
 * ========================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: transparent;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    height: 100%;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
}

/* --- HEADER --- */
.chat-header {
    background: #4461f2;
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

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

.header-avatar-container {
    width: 45px;
    height: 45px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-info {
    display: flex;
    flex-direction: column;
}

.header-name {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.header-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #00e676;
    border-radius: 50%;
}

.header-right {
    cursor: pointer;
    opacity: 0.8;
}
.header-right:hover { opacity: 1; }

/* --- MESSAGES AREA --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f9f9f9;
}

/* Wrapper for Bot Messages */
.bot-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

/* Wrapper for User Messages */
.user-wrapper {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px;
}

/* Avatars */
.bot-avatar {
    width: 35px;
    height: 35px;
    background: #673ab7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0px;
    z-index: 2;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #ccc;
    flex-shrink: 0;
    overflow: hidden;
}
.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-content {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.user-wrapper .msg-content {
    align-items: flex-end;
}

/* Bubbles */
.mensaje {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.bot-msg {
    background: #e2e4e9;
    color: #333;
    border-radius: 12px;
    border-top-left-radius: 0; /* Tail top-left */
}

.bot-msg::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 10px solid #e2e4e9;
    border-left: 10px solid transparent;
}

.user-msg {
    background: #3b096c; /* Dark purple */
    color: white;
    border-radius: 12px;
    border-bottom-right-radius: 0; /* Tail bottom-right */
}

.user-msg::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-bottom: 10px solid #3b096c;
    border-right: 10px solid transparent;
}

/* Timestamp */
.msg-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* --- SUGGESTIONS --- */
.chat-suggestions {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
    overflow-x: auto;
    background: white;
}
.chat-suggestions::-webkit-scrollbar { display: none; }

.suggestion-chip {
    background: #f1f1f1;
    color: #555;
    padding: 8px 15px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.suggestion-chip:hover { background: #e0e0e0; }

/* --- INPUT AREA --- */
.chat-input-container {
    background: white;
    padding: 15px;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.chat-input-box {
    display: flex;
    align-items: center;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 5px 15px;
}

.chat-input-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    outline: none;
    font-size: 14px;
    color: #333;
}

.send-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}
.send-btn:hover {
    background: #e4e6eb;
}

/* Miniaturas de Producto */
.producto-recomendado {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    background: white;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}
.producto-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
    margin-bottom: 10px;
}

/* Imagen en el detalle del producto */
.producto-img-detalle {
    width: 140px;
    height: 140px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    margin: 0 auto 12px auto;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ==========================================
   ANIMACIÓN "ESCRIBIENDO..."
   ========================================== */

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #e2e4e9;
    border-radius: 12px;
    border-top-left-radius: 0;
    width: fit-content;
    position: relative;
}

.typing-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 10px solid #e2e4e9;
    border-left: 10px solid transparent;
}

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

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

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

/* ==========================================
   ANIMACIONES DE APARICIÓN
   ========================================== */
@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-wrapper {
    animation: slideUpFade 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

/* ==========================================
   NUEVOS ESTILOS PARA BOTONES INTERACTIVOS
   ========================================== */

.bot-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.bot-btn-action {
    background: #ffffff;
    color: #4461f2;
    border: 1.5px solid #4461f2;
    padding: 12px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-decoration: none;
    display: block;
    box-shadow: 0 4px 6px rgba(68, 97, 242, 0.1);
}

.bot-btn-action:hover {
    background: #4461f2;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(68, 97, 242, 0.25);
}

.bot-btn-action:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(68, 97, 242, 0.15);
}

/* FORMULARIOS DENTRO DEL BOT */
.form-bot {
    margin-top: 12px;
    background: #ffffff;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e0e6ed;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.bot-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cfd7df;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.bot-input:focus {
    border-color: #4461f2;
    box-shadow: 0 0 0 3px rgba(68, 97, 242, 0.1);
}

.bot-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    background: #f1f5f9;
    color: #475569;
    transition: all 0.2s ease;
}

.bot-btn:hover {
    background: #e2e8f0;
}

.bot-btn-submit {
    background: #25D366;
    color: white;
    box-shadow: 0 4px 6px rgba(37, 211, 102, 0.2);
}

.bot-btn-submit:hover {
    background: #1fad53;
    transform: translateY(-1px);
    box-shadow: 0 6px 10px rgba(37, 211, 102, 0.3);
}

.bot-btn-submit:active {
    transform: translateY(1px);
}

@media (max-width: 480px) {
    .chat-container {
        border-radius: 0;
        border: none;
    }
    .chat-header {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
}