/* ==========================================================================
   AI Travel Assistant Chat Widget
   Floating chat widget styled to match the Abisiniya brand.
   ========================================================================== */

/* ---------- Variables ---------- */
:root {
    --ai-chat-primary: #2db838;
    --ai-chat-primary-dark: #239a2e;
    --ai-chat-primary-light: #eaf8eb;
    --ai-chat-bg: #ffffff;
    --ai-chat-msg-bg: #f1f5f9;
    --ai-chat-text: #1e293b;
    --ai-chat-text-light: #64748b;
    --ai-chat-border: #e2e8f0;
    --ai-chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --ai-chat-radius: 16px;
    --ai-chat-width: 380px;
    --ai-chat-height: 520px;
    --ai-chat-z: 9999;
}

/* ---------- Widget container ---------- */
.ai-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: var(--ai-chat-z);
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- Toggle button ---------- */
.ai-chat-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ai-chat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(45, 184, 56, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ai-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(45, 184, 56, 0.5);
    background: var(--ai-chat-primary-dark);
}

.ai-chat-toggle:active {
    transform: scale(0.96);
}

/* Notification badge */
.ai-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---------- Chat window ---------- */
.ai-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: var(--ai-chat-width);
    height: var(--ai-chat-height);
    background: var(--ai-chat-bg);
    border-radius: var(--ai-chat-radius);
    box-shadow: var(--ai-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aiChatSlideIn 0.25s ease-out;
    border: 1px solid var(--ai-chat-border);
}

@keyframes aiChatSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- Header ---------- */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--ai-chat-primary);
    color: #fff;
    flex-shrink: 0;
}

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

.ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.ai-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    line-height: 1.2;
}

.ai-chat-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.ai-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ---------- Messages area ---------- */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.ai-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* ---------- Message bubbles ---------- */
.ai-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-chat-msg-user {
    align-self: flex-end;
    background: var(--ai-chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-chat-msg-assistant {
    align-self: flex-start;
    background: var(--ai-chat-msg-bg);
    color: var(--ai-chat-text);
    border-bottom-left-radius: 4px;
}

/* Links inside assistant messages */
.ai-chat-msg-assistant a {
    color: var(--ai-chat-primary);
    text-decoration: underline;
    font-weight: 500;
}

.ai-chat-msg-assistant a:hover {
    color: var(--ai-chat-primary-dark);
}

/* Lists inside assistant messages */
.ai-chat-msg-assistant ul,
.ai-chat-msg-assistant ol {
    margin: 6px 0;
    padding-left: 18px;
}

.ai-chat-msg-assistant li {
    margin-bottom: 3px;
}

/* Bold/strong text */
.ai-chat-msg-assistant strong {
    font-weight: 600;
}

/* Error message styling */
.ai-chat-msg-error {
    align-self: flex-start;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-bottom-left-radius: 4px;
}

/* ---------- Typing indicator ---------- */
.ai-chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 8px;
    flex-shrink: 0;
}

.ai-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-chat-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ai-chat-primary);
    opacity: 0.4;
    animation: aiChatBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes aiChatBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.3;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.ai-chat-typing-text {
    font-size: 12px;
    color: var(--ai-chat-text-light);
}

/* ---------- Input area ---------- */
.ai-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--ai-chat-border);
    flex-shrink: 0;
    background: var(--ai-chat-bg);
}

.ai-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid var(--ai-chat-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
    background: #f8fafc;
    color: var(--ai-chat-text);
}

.ai-chat-input:focus {
    border-color: var(--ai-chat-primary);
    background: #fff;
}

.ai-chat-input::placeholder {
    color: #94a3b8;
}

.ai-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ai-chat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover {
    background: var(--ai-chat-primary-dark);
}

.ai-chat-send-btn:active {
    transform: scale(0.92);
}

.ai-chat-send-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.ai-chat-powered {
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    margin-top: 6px;
}

/* ---------- Mobile responsive ---------- */
@media (max-width: 480px) {
    .ai-chat-widget {
        bottom: 80px;
        right: 16px;
    }

    .ai-chat-toggle {
        width: 54px;
        height: 54px;
    }

    .ai-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        animation: aiChatSlideUp 0.25s ease-out;
    }

    @keyframes aiChatSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ---------- Ensure widget doesn't overlap scroll-to-top button ---------- */
.scroll-top {
    z-index: 9998 !important;
}
