/* ========================================
   CHATBOT - Valentina Rojas Tienda
   ======================================== */

:root {
    --primary: #e91e63;
    --primary-dark: #c2185b;
    --primary-light: #fce4ec;
    --secondary: #ff9800;
    --bg-chat: #f5f5f5;
    --bg-user: #e91e63;
    --bg-bot: #ffffff;
    --text-user: #ffffff;
    --text-bot: #333333;
    --text-muted: #888888;
    --shadow: 0 2px 20px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-lg: 20px;
}

/* ========================================
   BOTÓN FLOTANTE
   ======================================== */
.chatbot-float-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all 0.3s ease;
}

.chatbot-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 25px rgba(233, 30, 99, 0.4);
}

.chatbot-float-btn .chatbot-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-float-btn .chatbot-close-icon {
    display: none;
}

.chatbot-float-btn.active .chatbot-icon {
    display: none;
}

.chatbot-float-btn.active .chatbot-close-icon {
    display: flex;
}

/* ========================================
   NOTIFICACIÓN NO LEÍDA
   ======================================== */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ========================================
   VENTANA DEL CHAT
   ======================================== */
.chatbot-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--bg-chat);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

.chatbot-widget.open {
    display: flex;
}

/* ========================================
   HEADER
   ======================================== */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

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

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

.chatbot-header-title {
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-header-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    display: inline-block;
}

.chatbot-header-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chatbot-header-close:hover {
    background: rgba(255,255,255,0.25);
}

/* ========================================
   MESSAGES CONTAINER
   ======================================== */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #fafafa;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ========================================
   MESSAGE BUBBLES
   ======================================== */
.chatbot-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: msgIn 0.3s ease;
}

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

.chatbot-msg.bot {
    align-self: flex-start;
}

.chatbot-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chatbot-msg.bot .chatbot-msg-avatar {
    background: var(--primary-light);
}

.chatbot-msg.user .chatbot-msg-avatar {
    background: var(--primary);
    color: white;
}

.chatbot-msg-content {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-msg.bot .chatbot-msg-content {
    background: var(--bg-bot);
    color: var(--text-bot);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.chatbot-msg.user .chatbot-msg-content {
    background: var(--bg-user);
    color: var(--text-user);
    border-bottom-right-radius: 4px;
}

.chatbot-msg-content strong {
    font-weight: 600;
}

.chatbot-msg-content p {
    margin: 4px 0;
}

.chatbot-msg-content p:first-child {
    margin-top: 0;
}

.chatbot-msg-content p:last-child {
    margin-bottom: 0;
}

.chatbot-msg-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.chatbot-msg.user .chatbot-msg-time {
    color: rgba(255,255,255,0.7);
}

/* Product card inside message */
.chatbot-product-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 10px;
    margin: 8px 0;
    border-left: 3px solid var(--primary);
}

.chatbot-product-card .product-name {
    font-weight: 600;
    color: var(--primary-dark);
}

.chatbot-product-card .product-price {
    font-size: 15px;
    font-weight: 600;
    color: #2e7d32;
}

.chatbot-product-card .product-info {
    font-size: 12px;
    color: #666;
}

/* ========================================
   SUGGESTIONS
   ======================================== */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chatbot-suggestion-btn {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-suggestion-btn:hover {
    background: var(--primary);
    color: white;
}

/* ========================================
   TYPING INDICATOR
   ======================================== */
.chatbot-typing {
    align-self: flex-start;
    display: none;
    padding: 8px 0;
}

.chatbot-typing.active {
    display: flex;
}

.chatbot-typing-dots {
    background: var(--bg-bot);
    padding: 12px 16px;
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    animation: typingDot 1.4s infinite;
}

.chatbot-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { background: #ccc; transform: translateY(0); }
    30% { background: var(--primary); transform: translateY(-4px); }
}

/* ========================================
   INPUT AREA
   ======================================== */
.chatbot-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot-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;
}

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

.chatbot-input::placeholder {
    color: #aaa;
}

.chatbot-send-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chatbot-float-btn {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 24px;
    }
}

/* ========================================
   PAGE CHATBOT (full page version)
   ======================================== */
.chatbot-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.chatbot-page-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.chatbot-page-header h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.chatbot-page-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 16px;
}

.chatbot-page .chatbot-widget {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 500px;
    display: flex;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    border-radius: var(--radius-lg);
}

.chatbot-page .chatbot-messages {
    height: 400px;
}
