/* ─────────────────────────────────────────
   CHATBOT STYLES
   ───────────────────────────────────────── */

#chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: var(--font-sans);
}

/* Toggle Button */
#chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #1a1400;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), var(--shadow-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s ease;
}

#chatbot-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    background: var(--color-accent-dk);
}

#chatbot-toggle svg {
    width: 30px;
    height: 30px;
}

/* Chat Window */
#chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatbot-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chatbot-header {
    padding: var(--space-md);
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--color-accent);
}

.chatbot-header-text h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--color-accent);
    margin: 0;
}

.chatbot-header-text p {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0;
}

.chatbot-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 5px;
}

/* Messages Area */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

#chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 10px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
    animation: messageIn 0.3s ease-out forwards;
}

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

.message.bot {
    align-self: flex-start;
    background: var(--color-surface-2);
    color: var(--color-text);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--color-accent);
    color: #1a1400;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

/* Dish Recommendation in Chat */
.chat-dish-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-dish-card:hover {
    background: rgba(200, 169, 110, 0.1);
    border-color: var(--color-accent);
}

.chat-dish-card img {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.chat-dish-info {
    flex: 1;
}

.chat-dish-info h4 {
    font-size: 0.85rem;
    margin: 0;
    color: var(--color-text);
}

.chat-dish-info p {
    font-size: 0.75rem;
    color: var(--color-accent);
    margin: 2px 0 0;
    font-weight: 600;
}

/* Input Area */
.chatbot-input-area {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface-2);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 10px;
}

#chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--color-text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus {
    border-color: var(--color-accent);
}

#chatbot-send {
    background: var(--color-accent);
    color: #1a1400;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

#chatbot-send:hover {
    transform: scale(1.1);
}

#chatbot-send svg {
    width: 18px;
    height: 18px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--color-text-muted);
    border-radius: 50%;
    animation: typing 1s 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%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* ─── MOBILE FULL-SCREEN CHAT ─── */
@media (max-width: 480px) {

    #chatbot-container {
        bottom: 12px;
        right: 12px;
    }

    #chatbot-toggle {
        width: 52px;
        height: 52px;
    }

    #chatbot-toggle svg {
        width: 26px;
        height: 26px;
    }

    /* Fullscreen overlay */
    #chatbot-window {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        width: calc(100vw - 32px);
        height: calc(100vh - 80px);
        height: calc(100dvh - 80px);
        max-width: 400px;
        max-height: 600px;
        border-radius: 20px;
        border: 1px solid var(--color-border);
        z-index: 2000;
        opacity: 0;
        pointer-events: none;
    }

    #chatbot-window.open {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        pointer-events: all;
    }

    /* Header con safe-area para notch */
    .chatbot-header {
        padding: 12px 15px;
        padding-top: max(12px, env(safe-area-inset-top));
        gap: 10px;
    }

    .chatbot-header img {
        width: 32px;
        height: 32px;
    }

    .chatbot-header-text h3 {
        font-size: 1rem;
    }

    .chatbot-header-text p {
        font-size: 0.7rem;
    }

    .chatbot-close {
        padding: 8px;
    }

    .chatbot-close svg {
        width: 22px;
        height: 22px;
    }

    /* Mensajes */
    #chatbot-messages {
        padding: 12px;
        gap: 12px;
    }

    .message {
        max-width: 92%;
        padding: 10px 13px;
        font-size: 0.88rem;
        border-radius: 16px;
    }

    /* Tarjetas de platos - compactas */
    .chat-dish-card {
        padding: 8px;
        gap: 8px;
        margin-top: 6px;
        border-radius: 10px;
    }

    .chat-dish-card img {
        width: 48px;
        height: 48px;
        border-radius: 8px;
    }

    .chat-dish-card h4 {
        font-size: 0.82rem;
        line-height: 1.3;
    }

    /* Input pegado abajo, con safe-area */
    .chatbot-input-area {
        padding: 8px 12px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 8px;
    }

    #chatbot-input {
        font-size: 16px; /* Evita zoom en iOS */
        padding: 10px 14px;
        border-radius: 22px;
    }

    #chatbot-send {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    /* Ocultar botón toggle cuando el chat está abierto */
    #chatbot-toggle.hidden {
        display: none;
    }
}

/* ─── TABLET ─── */
@media (min-width: 481px) and (max-width: 768px) {
    #chatbot-window {
        width: 340px;
        height: 460px;
    }

    .chat-dish-card img {
        width: 50px;
        height: 50px;
    }
}
