/* ============================================================
   TONI CHAT WIDGET + BOOKING MODAL
   ============================================================ */

/* ---- BOOKING MODAL ---- */
.booking-modal {
    display: none; position: fixed; inset: 0; z-index: 2000;
    align-items: center; justify-content: center;
}
.booking-modal.open { display: flex; }

.booking-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
}
.booking-frame-wrap {
    position: relative; z-index: 1;
    width: 92vw; max-width: 680px;
    height: 88vh; max-height: 860px;
    background: #fff; border-radius: 20px;
    overflow: hidden; box-shadow: 0 24px 80px rgba(0,0,0,.35);
    display: flex; flex-direction: column;
    animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
}
.booking-frame-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; background: #18202c; flex-shrink: 0;
}
.booking-frame-header span {
    font-size: .85rem; font-weight: 600; color: rgba(255,255,255,.8);
    display: flex; align-items: center; gap: 8px;
}
.booking-frame-header span i { color: var(--teal-light); }
.booking-frame-actions { display: flex; align-items: center; gap: 10px; }
.booking-external {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .78rem; color: rgba(255,255,255,.6);
    transition: color .2s; background: none; border: none; cursor: pointer;
    padding: 4px 8px;
}
.booking-external:hover { color: var(--teal-light); }
.booking-close-btn {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,.1); border: none; cursor: pointer;
    color: rgba(255,255,255,.7); font-size: 1.1rem; display: flex;
    align-items: center; justify-content: center; transition: background .2s;
}
.booking-close-btn:hover { background: rgba(255,255,255,.2); }
.booking-frame-wrap iframe {
    flex: 1; border: none; width: 100%;
}

/* ---- TONI CHAT WIDGET ---- */
.toni-chat {
    position: fixed; bottom: 28px; right: 28px;
    z-index: 900; display: flex; flex-direction: column;
    align-items: flex-end; gap: 0;
}

/* Trigger button */
.toni-chat-btn {
    position: relative; background: none; border: none;
    cursor: pointer; padding: 0; outline: none;
}
.toni-chat-avatar {
    width: 76px; height: 76px; border-radius: 50%;
    overflow: hidden; border: 3px solid var(--white);
    box-shadow: 0 6px 24px rgba(0,0,0,.25);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;
    background: linear-gradient(135deg, var(--teal), var(--teal-light));
    will-change: transform;
}
.toni-chat-avatar img {
    width: 100%; height: 100%; object-fit: cover; object-position: center;
    image-rendering: -webkit-optimize-contrast;
}
.toni-chat-btn:hover .toni-chat-avatar {
    transform: scale(1.35);
    box-shadow: 0 14px 40px rgba(26,138,118,.45);
}
.toni-online-dot {
    position: absolute; bottom: 4px; right: 4px;
    width: 14px; height: 14px; border-radius: 50%;
    background: #22c55e; border: 2px solid var(--white);
    animation: pulse-dot 2s infinite;
}
.toni-tooltip {
    position: absolute; right: 76px; top: 50%; transform: translateY(-50%);
    background: var(--dark); color: var(--white);
    font-size: .78rem; font-weight: 600; white-space: nowrap;
    padding: 7px 14px; border-radius: 8px;
    pointer-events: none; opacity: 0; transition: opacity .25s;
}
.toni-tooltip::before {
    content: ''; position: absolute; right: -6px; top: 50%;
    transform: translateY(-50%); border: 6px solid transparent;
    border-left-color: var(--dark); border-right: none;
}
.toni-chat-btn:hover .toni-tooltip { opacity: 1; }

/* Chat panel */
.toni-chat-panel {
    position: absolute; bottom: 80px; right: 0;
    width: min(390px, calc(100vw - 32px)); background: var(--white);
    border-radius: 20px; box-shadow: 0 16px 56px rgba(0,0,0,.18);
    overflow: hidden; display: flex; flex-direction: column;
    transform-origin: bottom right;
    transform: scale(0.8) translateY(20px);
    opacity: 0; pointer-events: none;
    transition: transform .3s cubic-bezier(.34,1.3,.64,1), opacity .25s ease;
    max-height: 560px;
}
.toni-chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1; pointer-events: all;
}

/* Panel header */
.chat-panel-header {
    background: linear-gradient(135deg, #0b2220, #1a8a76);
    padding: 16px 18px; display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
.chat-header-avatar {
    width: 46px; height: 46px; border-radius: 50%; overflow: hidden;
    border: 2px solid rgba(255,255,255,.3); flex-shrink: 0;
    background: var(--teal);
}
.chat-header-avatar img {
    width: 100%; height: 100%; object-fit: cover; object-position: center;
}
.chat-header-info { flex: 1; }
.chat-header-info strong {
    display: block; color: var(--white); font-size: .92rem; font-weight: 700;
}
.chat-header-info span {
    font-size: .72rem; color: rgba(255,255,255,.65);
}
.chat-header-status {
    display: flex; align-items: center; gap: 5px;
    font-size: .7rem; color: rgba(255,255,255,.7); margin-top: 3px;
}
.chat-header-status .dot {
    width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
}
.chat-panel-close {
    background: rgba(255,255,255,.15); border: none; cursor: pointer;
    width: 30px; height: 30px; border-radius: 50%; color: var(--white);
    font-size: 1rem; display: flex; align-items: center; justify-content: center;
    transition: background .2s; flex-shrink: 0;
}
.chat-panel-close:hover { background: rgba(255,255,255,.25); }

/* Messages area */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 280px; background: #f8faf9;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Message bubbles */
.chat-msg { display: flex; gap: 8px; align-items: flex-end; }
.chat-msg.bot { justify-content: flex-start; }
.chat-msg.user { justify-content: flex-end; }

.chat-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
    flex-shrink: 0; background: var(--teal);
}
.chat-msg-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center; }

.chat-bubble {
    max-width: 78%; padding: 10px 14px; border-radius: 16px;
    font-size: .85rem; line-height: 1.55;
}
.chat-msg.bot .chat-bubble {
    background: var(--white); color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.chat-msg.user .chat-bubble {
    background: var(--teal); color: var(--white);
    border-bottom-right-radius: 4px;
}
.chat-bubble a {
    color: inherit; text-decoration: underline; font-weight: 600;
}

/* Botones inline enviados por n8n */
.chat-bubble .chat-btn {
    display: block; width: 100%; margin-top: 8px;
    padding: 10px 16px; border-radius: 20px;
    background: var(--teal); color: #fff;
    border: none; cursor: pointer; font-size: .84rem;
    font-weight: 600; font-family: inherit; text-align: center;
    transition: opacity .2s;
}
.chat-bubble .chat-btn:hover { opacity: .85; }
.chat-buttons-container { margin-top: 4px; }

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; align-items: center; padding: 12px 14px; }
.typing-indicator span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--muted); animation: typing-bounce .9s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }

/* Quick actions */
.chat-quick-actions {
    display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px;
    background: #f8faf9; flex-shrink: 0;
}
.quick-action-btn {
    font-size: .75rem; font-weight: 600; color: var(--teal);
    border: 1.5px solid var(--teal); border-radius: 50px;
    padding: 8px 14px; background: none; cursor: pointer;
    transition: all .2s; white-space: nowrap; min-height: 36px;
}
.quick-action-btn:hover { background: var(--teal); color: var(--white); }

/* Input area */
.chat-input-area {
    display: flex; gap: 8px; padding: 12px 14px;
    border-top: 1px solid var(--border); background: var(--white);
    flex-shrink: 0;
}
.chat-input-area input {
    flex: 1; border: 1.5px solid var(--border); border-radius: 50px;
    padding: 9px 16px; font-size: .875rem; font-family: var(--font);
    outline: none; transition: border-color .2s;
}
.chat-input-area input:focus { border-color: var(--teal); }
.chat-send-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--teal); border: none; cursor: pointer;
    color: var(--white); font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, transform .2s; flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--teal-dark); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Animations */
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
    50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Responsive */
@media (max-width: 480px) {
    .toni-chat { bottom: 16px; right: 16px; }
    .toni-chat-panel { width: calc(100vw - 32px); right: 0; }
    .booking-frame-wrap { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
}
