/* ===== AI Chat Widget ===== */

/* Active indicator animation */
@keyframes ai-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.ai-active-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #0d9488;
    animation: ai-pulse 1.5s ease-in-out infinite;
}

/* Typing cursor animation */
@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.typing-cursor::after {
    content: '|';
    animation: blink-cursor 0.8s step-end infinite;
    margin-left: 2px;
    color: #0d9488;
}

/* ===== Float Toggle Button ===== */
.chat-toggle {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #0d9488;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15), 0 8px 10px -6px rgba(0,0,0,0.1);
    transition: all 0.2s;
}
.chat-toggle:hover {
    background: #0f766e;
    transform: scale(1.05);
}
.chat-toggle:active {
    transform: scale(0.95);
}
.chat-toggle .material-symbols-outlined {
    font-size: 28px;
}
.chat-toggle-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ba1a1a;
    color: white;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid white;
}

/* ===== Chat Window (Float Mode) ===== */
.chat-window {
    position: fixed;
    bottom: 112px;
    right: 32px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    border-radius: 24px;
    background: #fff;
    border: 1px solid #bcc9c6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
}
.chat-window.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ===== Embedded Mode (index.html) ===== */
.chat-window.chat-embedded {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    border: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

/* ===== Chat Header ===== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: #0d9488;
    flex-shrink: 0;
}
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}
.chat-avatar .material-symbols-outlined {
    font-size: 20px;
}
.chat-header-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 16px;
    color: white;
    margin: 0;
}
.chat-header-status {
    font-size: 10px;
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin: 0;
    margin-top: 4px;
}
.chat-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.15s;
}
.chat-close:hover {
    background: rgba(255,255,255,0.1);
}
.chat-close .material-symbols-outlined {
    font-size: 18px;
}

/* ===== Venue Context Bar ===== */
.venue-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    background: #f0fdfa;
    border-bottom: 1px solid rgba(13, 148, 136, 0.15);
    font-size: 13px;
    color: #0d9488;
    flex-shrink: 0;
}
.venue-name {
    font-weight: 600;
}
.clear-context {
    cursor: pointer;
    opacity: 0.7;
    font-size: 12px;
}
.clear-context:hover {
    opacity: 1;
}

/* ===== Chat Messages ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8f9fd;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Message bubbles */
.message {
    max-width: 85%;
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}
.message.user {
    background: #0d9488;
    color: #fff;
    align-self: flex-end;
    border-top-right-radius: 4px;
}
.message.assistant {
    background: #fff;
    color: #191c1f;
    align-self: flex-start;
    border: 1px solid #bcc9c6;
    border-top-left-radius: 4px;
}
.message.assistant .answer {
    white-space: pre-line;
}
.message.error {
    background: #ffdad6;
    color: #93000a;
    border-color: #ba1a1a;
}

/* Sources section inside message */
.sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e1e2e6;
}
.sources-title {
    font-size: 12px;
    font-weight: 600;
    color: #6d7a77;
    margin-bottom: 6px;
}
.source-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 4px 0;
    color: #3d4947;
}
.confidence {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #f0fdfa;
    color: #0d9488;
    font-weight: 600;
}
.confidence.unverified {
    background: #fff8e1;
    color: #f57f17;
}

/* Suggestion inside message */
.suggestion {
    margin-top: 8px;
    font-size: 13px;
    color: #3d4947;
    font-style: italic;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 20px;
    align-self: flex-start;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bcc9c6;
    animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}
.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== Quick Actions ===== */
.quick-actions {
    display: flex;
    gap: 6px;
    padding: 10px 24px;
    flex-wrap: wrap;
    border-top: 1px solid #e1e2e6;
    background: #fff;
    flex-shrink: 0;
}
.quick-action {
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 9999px;
    border: 1px solid #bcc9c6;
    background: #fff;
    color: #3d4947;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    font-family: 'Inter', sans-serif;
}
.quick-action:hover {
    border-color: #0d9488;
    color: #0d9488;
}

/* ===== Chat Input ===== */
.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid #bcc9c6;
    background: #fff;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    padding: 10px 18px;
    border-radius: 9999px;
    border: none;
    background: #f2f3f8;
    font-size: 14px;
    color: #191c1f;
    font-family: 'Inter', sans-serif;
    outline: none;
}
.chat-input::placeholder {
    color: #6d7a77;
}
.chat-input:focus {
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.3);
}
.chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #0d9488;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.chat-send:hover {
    background: #0f766e;
}
.chat-send .material-symbols-outlined {
    font-size: 20px;
}

/* ===== Scrollbar ===== */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #bcc9c6;
    border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #6d7a77;
}

/* ===== Mobile Adjustments ===== */
@media (max-width: 640px) {
    .chat-window:not(.chat-embedded) {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
}
