/*
 * Zoe Chat Drawer Component
 * A modular chat drawer that can be included on any page
 *
 * Usage:
 * 1. Include this CSS: <link rel="stylesheet" href="/public/css/zoe-chat.css">
 * 2. Include the HTML partial (see zoe-chat.html or copy the markup)
 * 3. Include the JS: <script src="/public/js/zoe-chat.js"></script>
 */

/* ============================================
   Fixed Help Button
   ============================================ */
.zoe-help-btn {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--accent);
    color: white;
    font-size: 18px;
    font-weight: 600;
    padding: 16px 32px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(243, 112, 33, 0.3);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

.zoe-help-btn:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 112, 33, 0.4);
}

.zoe-help-btn.hidden {
    display: none;
}

.zoe-help-btn svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   Chat Drawer Backdrop
   ============================================ */
.zoe-chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.zoe-chat-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Chat Drawer Panel
   ============================================ */
.zoe-chat-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 450px;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.zoe-chat-drawer.active {
    transform: translateX(0);
}

/* ============================================
   Chat Header
   ============================================ */
.zoe-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: white;
    flex-shrink: 0;
}

.zoe-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoe-chat-back {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoe-chat-back:hover {
    background: var(--bg);
}

.zoe-chat-back svg {
    width: 24px;
    height: 24px;
}

.zoe-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoe-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px;
}

.zoe-chat-title-text h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    font-family: 'Montserrat', sans-serif;
    margin: 0;
}

.zoe-chat-title-text span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Chat Messages
   ============================================ */
.zoe-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

/* Spacer pushes messages to bottom when few messages */
.zoe-chat-spacer {
    flex: 1 1 auto;
    min-height: 0;
}

.zoe-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
}

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

.zoe-message.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Links in Zoe's messages */
.zoe-message.zoe a {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 600;
}

.zoe-message.zoe a:hover {
    color: var(--primary-dark);
}

/* ============================================
   Typing Indicator
   ============================================ */
.zoe-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 60px;
}

.zoe-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: zoe-typing 1.4s infinite;
}

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

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

/* ============================================
   Chat Input
   ============================================ */
.zoe-chat-input-container {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    background: white;
    flex-shrink: 0;
}

.zoe-chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
}

.zoe-chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.zoe-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.zoe-chat-send:hover {
    background: var(--accent-dark);
}

.zoe-chat-send:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.zoe-chat-send svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 768px) {
    .zoe-chat-drawer {
        max-width: 100%;
    }

    .zoe-help-btn {
        top: 5px;
        right: 16px;
        bottom: auto;
        font-size: 16px;
        padding: 10px 20px;
        background: var(--primary);
    }

    .first-text {
        display: none;
    }
}
