/* =============================================
   CHATBOT WIDGET STYLES
   ============================================= */

/* Botón flotante del chat */
.chatbot-toggle {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #2ed573;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chatbot-toggle i {
    font-size: 24px;
    color: white;
    transition: transform 0.3s ease;
}

.chatbot-toggle.active i {
    transform: rotate(90deg);
}

.chatbot-toggle .chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Ventana del chat */
.chatbot-window {
    position: fixed;
    bottom: 170px;
    right: 20px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.chatbot-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header del chat */
.chatbot-header {
    background-color: #94dab1;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.chatbot-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-info span {
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #2ed573;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-close {
    margin-left: auto;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chatbot-close:hover {
    opacity: 1;
}

/* Área de mensajes */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

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

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

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

/* Mensajes */
.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeInUp 0.3s ease;
}

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

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

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

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

.chat-message.bot .avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-message.user .avatar {
    background: #e9ecef;
    color: #495057;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
}

.chat-message.bot .chat-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message.user .chat-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Productos en el chat */
.chat-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.chat-product-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.chat-product-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.chat-product-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    background: #f1f1f1;
}

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

.chat-product-name {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #667eea;
}

.chat-product-price .original {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
    font-weight: normal;
    margin-left: 5px;
}

.chat-product-stock {
    font-size: 11px;
    margin-top: 2px;
}

.chat-product-stock.in-stock {
    color: #2ed573;
}

.chat-product-stock.out-stock {
    color: #ff4757;
}

/* Sugerencias */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chat-suggestion {
    background: #f0f0f0;
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #555;
}

.chat-suggestion:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Input del chat */
.chatbot-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chatbot-input input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input input:focus {
    border-color: #667eea;
}

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

.chatbot-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-input button:hover {
    transform: scale(1.05);
}

.chatbot-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =============================================
   RESPONSIVE STYLES
   ============================================= */

/* Tablets y pantallas medianas */
@media (max-width: 768px) {
    .chatbot-toggle {
        bottom: 90px;
        right: 15px;
        width: 55px;
        height: 55px;
    }

    .chatbot-toggle i {
        font-size: 22px;
    }

    .chatbot-window {
        width: 340px;
        height: 450px;
        bottom: 155px;
        right: 15px;
    }

    .chatbot-header {
        padding: 14px 16px;
    }

    .chatbot-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .chatbot-info h4 {
        font-size: 15px;
    }

    .chatbot-messages {
        padding: 15px;
    }

    .chat-bubble {
        padding: 10px 14px;
        font-size: 13px;
    }

    .chatbot-input {
        padding: 12px;
    }

    .chatbot-input input {
        padding: 10px 16px;
        font-size: 14px;
    }

    .chatbot-input button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* Móviles - Ventana pequeña */
@media (max-width: 576px) {
    .chatbot-toggle {
        bottom: 80px;
        right: 10px;
        width: 50px;
        height: 50px;
        z-index: 9998;
    }

    .chatbot-toggle i {
        font-size: 20px;
    }

    .chatbot-window {
        position: fixed;
        bottom: 140px;
        right: 10px;
        left: 10px;
        width: calc(100% - 20px);
        max-width: none;
        height: 60vh;
        max-height: 400px;
        border-radius: 16px;
        z-index: 99999;
    }

    .chatbot-header {
        padding: 12px 14px;
        border-radius: 16px 16px 0 0;
    }

    .chatbot-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .chatbot-info h4 {
        font-size: 14px;
    }

    .chatbot-info span {
        font-size: 11px;
    }

    .chatbot-close {
        font-size: 20px;
        padding: 8px;
    }

    .chatbot-messages {
        padding: 10px;
        gap: 8px;
    }

    .chat-message {
        max-width: 90%;
    }

    .chat-message .avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .chat-bubble {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 14px;
    }

    .chat-product-card {
        padding: 8px;
    }

    .chat-product-image {
        width: 45px;
        height: 45px;
        border-radius: 6px;
    }

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

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

    .chat-suggestions {
        gap: 5px;
        margin-top: 8px;
    }

    .chat-suggestion {
        padding: 6px 10px;
        font-size: 11px;
    }

    .chatbot-input {
        padding: 10px;
        border-radius: 0 0 16px 16px;
    }

    .chatbot-input input {
        padding: 10px 14px;
        font-size: 16px;
        border-radius: 20px;
    }

    .chatbot-input button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 360px) {
    .chatbot-header {
        padding: 12px;
        gap: 10px;
    }

    .chatbot-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .chatbot-info h4 {
        font-size: 14px;
    }

    .chatbot-info span {
        font-size: 11px;
    }

    .chat-product-image {
        width: 45px;
        height: 45px;
    }
}

/* Modo landscape en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .chatbot-window {
        height: 100%;
        max-height: 100vh;
    }

    .chatbot-messages {
        max-height: calc(100vh - 140px);
    }
}
