/* ─── ABRAKEEPS CHATBOT AUTO-REPLY UI ─── */

:root {
    --cb-primary: #6b3d2e;
    --cb-primary-dark: #2a150b;
    --cb-warm: #a0522d;
    --cb-green: #2d5a3d;
    --cb-surface: rgba(250, 245, 236, 0.96);
    --cb-surface-card: #f2ece2;
    --cb-text-main: #2a150b;
    --cb-text-muted: #6b3d2e;
    --cb-border: rgba(107, 61, 46, 0.16);
    --cb-shadow: 0 12px 36px rgba(42, 21, 11, 0.22);
}

body.dark-mode {
    --cb-surface: rgba(22, 34, 26, 0.94);
    --cb-surface-card: #223226;
    --cb-text-main: #f5f2ed;
    --cb-text-muted: #c2bba8;
    --cb-border: rgba(255, 255, 255, 0.12);
    --cb-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
}

/* Floating Trigger Button - Fixed Side Docked */
.chatbot-toggle-btn {
    position: fixed;
    bottom: 96px;
    width: 56px;
    height: 56px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-warm) 0%, var(--cb-primary) 50%, var(--cb-primary-dark) 100%);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 20px rgba(42, 21, 11, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: grab;
    z-index: 995;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, opacity 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    will-change: transform, left, top;
}

.chatbot-toggle-btn.dock-right {
    right: 24px;
    left: auto;
}

.chatbot-toggle-btn.dock-left {
    left: 24px;
    right: auto;
}

.chatbot-toggle-btn.is-dragging {
    cursor: grabbing !important;
    transition: none !important;
    transform: scale(1.12) !important;
    box-shadow: 0 14px 34px rgba(42, 21, 11, 0.5) !important;
    z-index: 1001 !important;
}

.chatbot-toggle-btn.is-snapping {
    transition: left 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), right 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), top 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), transform 0.2s ease !important;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 26px rgba(42, 21, 11, 0.45);
}

.chatbot-toggle-btn:active {
    transform: scale(0.95);
}

.chatbot-toggle-btn:focus-visible {
    outline: 3px solid var(--cb-warm);
    outline-offset: 3px;
}

/* Drawer and Modal Compatibility: Yield completely when any drawer/modal is active */
body.mobile-drawer-open .chatbot-toggle-btn,
body.mobile-drawer-open .chatbot-container,
body.nearby-drawer-open .chatbot-toggle-btn,
body.nearby-drawer-open .chatbot-container,
body.modal-open .chatbot-toggle-btn,
body.modal-open .chatbot-container {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Chatbot Dialog Container */
.chatbot-container {
    position: fixed;
    bottom: 92px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 530px;
    max-height: calc(100dvh - 120px);
    background: var(--cb-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--cb-border);
    border-radius: 20px;
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity 0.22s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), left 0.25s ease, right 0.25s ease;
    box-sizing: border-box;
}

.chatbot-container.dock-right {
    right: 24px;
    left: auto;
}

.chatbot-container.dock-left {
    left: 24px;
    right: auto;
}

.chatbot-container.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--cb-primary-dark) 0%, var(--cb-primary) 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.chatbot-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
    line-height: 1.2;
}

.chatbot-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    box-shadow: 0 0 8px #2ecc71;
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-dock-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease, opacity 0.2s ease;
    opacity: 0.85;
}

.chatbot-dock-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    opacity: 1;
}

.chatbot-dock-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.chatbot-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease, opacity 0.2s ease;
    opacity: 0.85;
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    opacity: 1;
}

.chatbot-close-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Chat Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(107, 61, 46, 0.2);
    border-radius: 10px;
}

/* Message Bubbles */
.chatbot-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: cbFadeIn 0.2s ease-out;
}

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

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

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

.chatbot-msg-bubble {
    padding: 11px 15px;
    font-size: 0.92rem;
    line-height: 1.45;
    word-break: break-word;
    box-sizing: border-box;
}

.chatbot-msg.bot .chatbot-msg-bubble {
    background: var(--cb-surface-card);
    color: var(--cb-text-main);
    border: 1px solid var(--cb-border);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.chatbot-msg.user .chatbot-msg-bubble {
    background: linear-gradient(135deg, var(--cb-warm) 0%, var(--cb-primary) 100%);
    color: #ffffff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 2px 8px rgba(107, 61, 46, 0.25);
}

.chatbot-msg-time {
    font-size: 0.68rem;
    color: var(--cb-text-muted);
    opacity: 0.7;
    margin-top: 3px;
    padding: 0 4px;
}

.chatbot-msg.user .chatbot-msg-time {
    align-self: flex-end;
}

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

/* Quick Suggestion Chips */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
    background: var(--cb-surface);
    border-top: 1px solid var(--cb-border);
    flex-shrink: 0;
    max-height: 105px;
    overflow-y: auto;
    box-sizing: border-box;
    transition: max-height 0.2s ease, padding 0.2s ease;
}

.chatbot-suggestions:empty {
    display: none;
    padding: 0;
    border-top: none;
}

.chatbot-chip {
    background: rgba(160, 82, 45, 0.09);
    border: 1px solid rgba(160, 82, 45, 0.28);
    color: var(--cb-primary);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

body.dark-mode .chatbot-chip {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--cb-text-main);
}

.chatbot-chip:hover {
    background: var(--cb-primary);
    color: #ffffff;
    border-color: var(--cb-primary);
    transform: translateY(-1px);
}

.chatbot-chip:active {
    transform: scale(0.97);
}

.chatbot-chip:focus-visible {
    outline: 2px solid var(--cb-warm);
    outline-offset: 1px;
}

/* Typing Indicator Animation */
.chatbot-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cb-primary);
    opacity: 0.4;
    animation: cbBounce 1.2s infinite ease-in-out;
}

body.dark-mode .chatbot-typing span {
    background: #ffffff;
}

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

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

@keyframes cbBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-5px); opacity: 0.95; }
}

/* Input Form Area */
.chatbot-input-area {
    padding: 12px 14px;
    background: var(--cb-surface);
    border-top: 1px solid var(--cb-border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    box-sizing: border-box;
}

.chatbot-input {
    flex: 1;
    min-height: 44px;
    /* Font size MUST be at least 16px to avoid iOS safari auto-zoom */
    font-size: 16px !important;
    font-family: inherit;
    padding: 9px 16px;
    border: 1px solid var(--cb-border);
    border-radius: 24px;
    outline: none;
    background: var(--cb-surface-card);
    color: var(--cb-text-main);
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-input:focus {
    border-color: var(--cb-warm);
    box-shadow: 0 0 0 3px rgba(160, 82, 45, 0.16);
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--cb-warm) 0%, var(--cb-primary) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    touch-action: manipulation;
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-send-btn:focus-visible {
    outline: 2px solid var(--cb-warm);
    outline-offset: 2px;
}

/* ─── MOBILE RESPONSIVENESS ─── */

/* Mobile Portrait & Small Screens */
@media (max-width: 600px) {
    .chatbot-toggle-btn {
        bottom: 85px;
    }

    .chatbot-toggle-btn.dock-right {
        right: 16px;
        left: auto;
    }

    .chatbot-toggle-btn.dock-left {
        left: 16px;
        right: auto;
    }

    .chatbot-container {
        top: auto !important;
        bottom: 12px !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
        max-width: calc(100vw - 24px) !important;
        height: min(540px, calc(100dvh - 24px)) !important;
        border-radius: 16px;
    }

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

    .chatbot-messages {
        padding: 12px;
    }

    .chatbot-input-area {
        padding: 10px 12px;
    }
}

/* Mobile Landscape (Short viewport height) */
@media (max-height: 500px) {
    .chatbot-container {
        top: 8px !important;
        bottom: 8px !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
        max-width: calc(100vw - 24px) !important;
        height: auto !important;
        max-height: calc(100dvh - 16px) !important;
        border-radius: 12px;
    }

    .chatbot-header {
        padding: 6px 12px;
    }

    .chatbot-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }

    .chatbot-title {
        font-size: 0.95rem;
    }

    .chatbot-close-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 1.3rem;
    }

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

    .chatbot-msg-bubble {
        padding: 8px 12px;
        font-size: 0.88rem;
    }

    .chatbot-input-area {
        padding: 6px 10px;
    }

    .chatbot-input {
        min-height: 44px;
        padding: 6px 14px;
    }

    .chatbot-send-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

