/**
 * HyperFastWeb AI Chat Assistant - Picostrap (Bootstrap 5) Widget Styles
 * Custom-tailored to HyperFastWeb / Picostrap Theme Settings
 * 
 * Palette from pico-settings-export-09-09-2026.json:
 * - body-bg: #212529 (Dark Charcoal)
 * - body-color: #fffffa (Warm Off-White)
 * - warning / accent: #ffb330 (Amber / Gold)
 * - info: #3e78b2 (Steel Blue)
 * - success: #69b578 (Emerald Green)
 * - danger: #ba1200 (Crimson Red)
 * - link-color: #c4ac5c
 */

:root {
    --ai-bg-dark: #1a1d21;
    --ai-bg-body: #14171a;
    --ai-bg-header: #212529;
    --ai-bg-surface: rgba(255, 255, 250, 0.06);
    --ai-text-main: #fffffa;
    --ai-text-muted: rgba(255, 255, 250, 0.65);
    --ai-gold: #ffb330;
    --ai-gold-hover: #e59c1c;
    --ai-gold-border: rgba(255, 179, 48, 0.35);
    --ai-border: rgba(255, 255, 250, 0.12);
    --ai-blue: #3e78b2;
    --ai-green: #69b578;
}

/* ==========================================================================
   1. FLOATING LAUNCHER BUTTON
   ========================================================================== */
.ai-widget-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-gold) 0%, #f5a31a 100%);
    color: #212529;
    border: 2px solid rgba(255, 255, 255, 0.4);
    cursor: pointer;
    box-shadow: 0 0.5rem 1.75rem rgba(255, 179, 48, 0.4), 0 0.25rem 0.75rem rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.ai-widget-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 0.75rem 2.25rem rgba(255, 179, 48, 0.6), 0 0.35rem 1rem rgba(0, 0, 0, 0.4);
}

.ai-widget-launcher svg {
    width: 28px;
    height: 28px;
    fill: #212529 !important;
}

.ai-widget-launcher .ai-icon-close { display: none; }
.ai-widget-launcher.ai-active .ai-icon-chat { display: none; }
.ai-widget-launcher.ai-active .ai-icon-close { display: block; }

/* ==========================================================================
   2. CHAT CONTAINER WINDOW (DARK GLASSMORPHISM)
   ========================================================================== */
.ai-widget-container {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background-color: var(--ai-bg-dark);
    color: var(--ai-text-main);
    border-radius: 1.25rem;
    box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 179, 48, 0.12);
    border: 1px solid var(--ai-gold-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ai-widget-container.ai-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ==========================================================================
   3. HEADER
   ========================================================================== */
.ai-widget-header {
    background: linear-gradient(135deg, #212529 0%, #171a1d 100%);
    color: var(--ai-text-main);
    padding: 0.95rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--ai-gold-border);
}

.ai-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-gold) 0%, #e0981a 100%);
    color: #212529;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--ai-green);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px var(--ai-green);
}

.ai-widget-header h6 {
    font-family: 'Lato', sans-serif;
    color: var(--ai-text-main) !important;
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-header-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 250, 0.12);
    border: 1px solid rgba(255, 255, 250, 0.22);
    color: var(--ai-text-main) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    outline: none;
}

.ai-header-close-btn:hover,
.ai-header-close-btn:active {
    background-color: var(--ai-gold);
    color: #212529 !important;
    border-color: var(--ai-gold);
    transform: scale(1.08);
}

.ai-header-close-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor !important;
}

/* ==========================================================================
   4. CHAT BODY & MESSAGES
   ========================================================================== */
.ai-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background-color: var(--ai-bg-body);
    scroll-behavior: smooth;
}

.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    font-size: 0.925rem;
    line-height: 1.5;
    word-break: break-word;
}

.ai-message.ai-user {
    align-self: flex-end;
}

.ai-message.ai-assistant {
    align-self: flex-start;
}

.ai-bubble {
    padding: 0.8rem 1.05rem;
    border-radius: 1rem;
}

/* AI Message Bubble (Dark Glass with Crisp Warm-White Text) */
.ai-assistant .ai-bubble {
    background-color: var(--ai-bg-surface);
    color: var(--ai-text-main);
    border: 1px solid var(--ai-border);
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* User Message Bubble (Signature Gold Accent with Charcoal Text) */
.ai-user .ai-bubble {
    background: linear-gradient(135deg, var(--ai-gold) 0%, #f5a31a 100%);
    color: #1a1d21;
    font-weight: 500;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 4px 12px rgba(255, 179, 48, 0.25);
}

.ai-bubble p { margin-bottom: 0.5rem; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 0.25rem 0 0.5rem 1.25rem; padding: 0; }
.ai-bubble a { color: var(--ai-gold); text-decoration: underline; font-weight: 600; }
.ai-user .ai-bubble a { color: #1a1d21; font-weight: bold; }

.ai-msg-time {
    font-size: 0.725rem;
    color: var(--ai-text-muted);
    margin-top: 4px;
    align-self: flex-end;
}
.ai-assistant .ai-msg-time {
    align-self: flex-start;
}

/* ==========================================================================
   5. CALENDAR BUTTONS (BOOKING CONFIRMATION)
   ========================================================================== */
.ai-calendar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 250, 0.1);
}

.ai-btn-calendar {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background-color: rgba(255, 179, 48, 0.12);
    border: 1px solid var(--ai-gold);
    color: var(--ai-gold) !important;
    font-weight: 600;
    transition: all 0.2s ease;
}

.ai-btn-calendar:hover {
    background-color: var(--ai-gold);
    color: #212529 !important;
    transform: translateY(-1px);
}

/* ==========================================================================
   6. TYPING INDICATOR
   ========================================================================== */
.ai-typing {
    display: none;
    align-self: flex-start;
    background-color: var(--ai-bg-surface);
    border: 1px solid var(--ai-border);
    padding: 0.65rem 1rem;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    gap: 5px;
    align-items: center;
}

.ai-typing.ai-visible { display: flex; }

.ai-typing span {
    width: 6px;
    height: 6px;
    background-color: var(--ai-gold);
    border-radius: 50%;
    animation: ai-bounce 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ==========================================================================
   7. QUICK SUGGESTIONS (CHIPS)
   ========================================================================== */
.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.65rem 1rem;
    background-color: var(--ai-bg-dark);
    border-top: 1px solid var(--ai-border);
}

.ai-chip {
    background-color: rgba(255, 179, 48, 0.08);
    color: var(--ai-gold) !important;
    border: 1px solid var(--ai-gold-border);
    border-radius: 50rem;
    padding: 0.3rem 0.85rem;
    font-size: 0.775rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-chip:hover {
    background-color: var(--ai-gold);
    color: #212529 !important;
    border-color: var(--ai-gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 179, 48, 0.25);
}

/* ==========================================================================
   8. FOOTER & USER INPUT
   ========================================================================== */
.ai-widget-footer {
    background-color: var(--ai-bg-dark);
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.ai-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 250, 0.05);
    border: 1px solid var(--ai-border);
    border-radius: 50rem;
    padding: 0.4rem 0.95rem;
    transition: border-color 0.2s ease;
}

.ai-input-wrapper:focus-within {
    border-color: var(--ai-gold);
    background-color: rgba(255, 255, 250, 0.08);
}

.ai-textarea {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--ai-text-main);
    resize: none;
    max-height: 80px;
    outline: none;
    line-height: 1.4;
}

.ai-textarea::placeholder {
    color: var(--ai-text-muted);
}

.ai-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--ai-gold) 0%, #f5a31a 100%);
    color: #212529;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 179, 48, 0.3);
}

.ai-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #212529 !important;
}

.ai-send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(255, 179, 48, 0.5);
}

.ai-send-btn:disabled {
    background: rgba(255, 255, 250, 0.15);
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}
.ai-send-btn:disabled svg {
    fill: rgba(255, 255, 250, 0.4) !important;
}

/* ==========================================================================
   9. TARGET PULSE HIGHLIGHT (E.G. ROI CALCULATOR FOCUS)
   ========================================================================== */
@keyframes ai-pulse-highlight {
    0% { outline: 3px solid rgba(255, 179, 48, 0.9); box-shadow: 0 0 0 0 rgba(255, 179, 48, 0.5); }
    70% { outline: 3px solid rgba(255, 179, 48, 0.2); box-shadow: 0 0 0 16px rgba(255, 179, 48, 0); }
    100% { outline: 3px solid transparent; box-shadow: 0 0 0 0 rgba(255, 179, 48, 0); }
}

.ai-element-highlighted {
    animation: ai-pulse-highlight 2.2s cubic-bezier(0, 0, 0.2, 1) 2;
    border-radius: 0.75rem;
}

/* ==========================================================================
   10. MOBILE RESPONSIVENESS & SAFE-AREA INSETS
   ========================================================================== */
@media (max-width: 576px) {
    body.ai-modal-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    .ai-widget-launcher {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .ai-widget-launcher svg {
        width: 26px;
        height: 26px;
    }

    /* Hide the floating launcher on mobile when chat is open so it NEVER blocks the input or send button */
    #ai-assistant-root.ai-chat-open .ai-widget-launcher {
        display: none !important;
    }

    .ai-widget-container {
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        z-index: 100000 !important;
    }

    /* Ensure header respects iPhone notch / Android status bar */
    .ai-widget-header {
        padding-top: max(1.15rem, env(safe-area-inset-top, 16px)) !important;
        padding-bottom: 0.85rem !important;
        padding-left: max(1.1rem, env(safe-area-inset-left, 16px)) !important;
        padding-right: max(1.1rem, env(safe-area-inset-right, 16px)) !important;
    }

    /* Extra prominent, comfortable touch target on mobile */
    .ai-header-close-btn {
        width: 44px !important;
        height: 44px !important;
        background: rgba(255, 255, 250, 0.18) !important;
        border: 1px solid rgba(255, 255, 250, 0.35) !important;
    }

    .ai-header-close-btn svg {
        width: 24px !important;
        height: 24px !important;
    }

    /* Ensure footer respects iPhone home indicator bar */
    .ai-widget-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 16px)) !important;
        padding-left: max(1rem, env(safe-area-inset-left, 16px)) !important;
        padding-right: max(1rem, env(safe-area-inset-right, 16px)) !important;
    }
}
