/* ── Grana Terra Chat IA ── */

:root {
    --gt-green:      #2d6a4f;
    --gt-green-dark: #1b4332;
    --gt-green-light:#52b788;
    --gt-bg:         #f8faf7;
    --gt-text:       #1a1a1a;
    --gt-muted:      #6b7280;
    --gt-white:      #ffffff;
    --gt-shadow:     0 8px 32px rgba(0,0,0,0.15);
    --gt-radius:     16px;
    --gt-radius-sm:  10px;
}

/* ── Bubble ─────────────────────────────────── */

#gt-chat-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99998;
    width: 60px;
    height: 60px;
    background: var(--gt-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--gt-shadow);
    transition: transform 0.2s ease, background 0.2s ease;
    color: var(--gt-white);
}

#gt-chat-bubble:hover {
    transform: scale(1.08);
    background: var(--gt-green-dark);
}

#gt-chat-bubble svg {
    width: 26px;
    height: 26px;
}

#gt-chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Window ─────────────────────────────────── */

#gt-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 99999;
    width: 360px;
    max-height: 560px;
    background: var(--gt-white);
    border-radius: var(--gt-radius);
    box-shadow: var(--gt-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

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

/* ── Header ─────────────────────────────────── */

#gt-chat-header {
    background: linear-gradient(135deg, var(--gt-green-dark), var(--gt-green));
    color: var(--gt-white);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#gt-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#gt-chat-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

#gt-chat-header-info strong {
    display: block;
    font-size: 15px;
    line-height: 1.2;
}

#gt-chat-header-info span {
    font-size: 11px;
    opacity: 0.8;
}

#gt-chat-close {
    background: none;
    border: none;
    color: var(--gt-white);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    opacity: 0.8;
    transition: opacity 0.15s;
    line-height: 1;
}

#gt-chat-close:hover { opacity: 1; }

/* ── Messages ───────────────────────────────── */

#gt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--gt-bg);
    scroll-behavior: smooth;
}

#gt-chat-messages::-webkit-scrollbar { width: 4px; }
#gt-chat-messages::-webkit-scrollbar-track { background: transparent; }
#gt-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.gt-msg {
    display: flex;
    max-width: 88%;
}

.gt-msg-bot  { align-self: flex-start; }
.gt-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.gt-msg-bubble {
    padding: 10px 13px;
    border-radius: var(--gt-radius-sm);
    line-height: 1.55;
    word-break: break-word;
}

.gt-msg-bot .gt-msg-bubble {
    background: var(--gt-white);
    color: var(--gt-text);
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.gt-msg-user .gt-msg-bubble {
    background: var(--gt-green);
    color: var(--gt-white);
    border-bottom-right-radius: 3px;
}

.gt-msg-bubble a {
    color: var(--gt-green-light);
    text-decoration: underline;
}

.gt-msg-user .gt-msg-bubble a {
    color: #b7e4c7;
}

/* Typing indicator */
.gt-typing .gt-msg-bubble {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
}

.gt-dot {
    width: 7px;
    height: 7px;
    background: var(--gt-muted);
    border-radius: 50%;
    animation: gt-bounce 1.2s infinite ease-in-out;
}
.gt-dot:nth-child(2) { animation-delay: 0.2s; }
.gt-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes gt-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ── Quick replies ──────────────────────────── */

#gt-chat-quick-replies {
    padding: 8px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--gt-bg);
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.gt-quick {
    background: var(--gt-white);
    border: 1.5px solid var(--gt-green-light);
    color: var(--gt-green-dark);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}

.gt-quick:hover {
    background: var(--gt-green);
    color: var(--gt-white);
    border-color: var(--gt-green);
}

/* ── Input area ─────────────────────────────── */

#gt-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: var(--gt-white);
    flex-shrink: 0;
}

#gt-chat-input {
    flex: 1;
    border: 1.5px solid #d1d5db;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 90px;
    overflow-y: auto;
    transition: border-color 0.15s;
    color: var(--gt-text);
}

#gt-chat-input:focus {
    border-color: var(--gt-green-light);
}

#gt-chat-send {
    width: 38px;
    height: 38px;
    background: var(--gt-green);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    color: var(--gt-white);
}

#gt-chat-send:hover  { background: var(--gt-green-dark); }
#gt-chat-send:active { transform: scale(0.93); }
#gt-chat-send svg    { width: 18px; height: 18px; }

/* ── Responsive ─────────────────────────────── */

@media (max-width: 420px) {
    #gt-chat-window {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 90px;
        max-height: 70vh;
    }
    #gt-chat-bubble {
        right: 16px;
        bottom: 20px;
    }
}

/* ── Botón agregar al carrito ───────────────────────────────── */

.gt-add-to-cart-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    background: linear-gradient(135deg, var(--gt-green), var(--gt-green-light));
    border: none;
    color: var(--gt-white);
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 3px 12px rgba(45,106,79,0.35);
    letter-spacing: 0.03em;
}

.gt-add-to-cart-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(45,106,79,0.45);
}

.gt-add-to-cart-btn:disabled {
    opacity: 0.85;
    cursor: default;
    transform: none;
}
