/**
 * Public Fast AI Assistant - Stylesheet
 * Premium Glassmorphic Design System
 */

:root {
    --ai-primary: #FF5A1F;
    --ai-secondary: #F97316;
    --ai-bg-light: rgba(255, 255, 255, 0.85);
    --ai-bg-dark: rgba(17, 24, 39, 0.92);
    --ai-text-light: #1f2937;
    --ai-text-dark: #f3f4f6;
    --ai-border-light: rgba(255, 90, 31, 0.15);
    --ai-border-dark: rgba(255, 90, 31, 0.3);
}

/* 1. Floating AI Launcher Button */
.ai-launcher-btn {
    position: fixed !important;
    right: 25px !important;
    bottom: 25px !important;
    width: 65px !important;
    height: 65px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary)) !important;
    cursor: pointer !important;
    box-shadow: 0 8px 25px rgba(255, 90, 31, 0.4) !important;
    border: 2.5px solid rgba(255, 255, 255, 0.8) !important;
    z-index: 9999 !important;
    padding: 2px !important;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
    animation: ai-float 4s ease-in-out infinite, ai-glowing-ring 2.5s infinite !important;
    overflow: hidden !important; /* Keep shimmer inside border */
}
.ai-launcher-btn::before {
    content: '' !important;
    position: absolute !important;
    top: -50% !important;
    left: -150% !important;
    width: 200% !important;
    height: 200% !important;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 30%,
        rgba(255, 255, 255, 0.7) 50%,
        rgba(255, 255, 255, 0.3) 70%,
        rgba(255, 255, 255, 0) 100%
    ) !important;
    transform: rotate(30deg) !important;
    transition: none !important;
    animation: ai-shimmer 3.5s infinite ease-in-out !important;
    z-index: 10 !important;
    pointer-events: none !important;
}
.ai-launcher-btn img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    transition: transform 0.5s ease !important;
}
.ai-launcher-btn:hover {
    transform: translateY(-10px) scale(1.12) rotate(5deg) !important;
    box-shadow: 0 15px 35px rgba(255, 90, 31, 0.6), 0 0 25px rgba(255, 90, 31, 0.4) !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
}
.ai-launcher-btn:hover img {
    transform: scale(1.05) !important;
}
.ai-launcher-btn:active {
    transform: scale(0.95) !important;
}

/* Tooltip for launcher */
.ai-launcher-btn::after {
    content: "Ask Public Fast AI";
    position: absolute;
    right: 78px;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    background: rgba(17, 24, 39, 0.9);
    color: #fff;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.ai-launcher-btn:hover::after {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

@keyframes ai-float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}
@keyframes ai-glowing-ring {
    0% {
        box-shadow: 0 8px 25px rgba(255, 90, 31, 0.4), 0 0 0 0 rgba(255, 90, 31, 0.5) !important;
    }
    70% {
        box-shadow: 0 8px 25px rgba(255, 90, 31, 0.4), 0 0 0 15px rgba(255, 90, 31, 0) !important;
    }
    100% {
        box-shadow: 0 8px 25px rgba(255, 90, 31, 0.4), 0 0 0 0 rgba(255, 90, 31, 0) !important;
    }
}
@keyframes ai-shimmer {
    0% {
        left: -150%;
    }
    30% {
        left: 150%;
    }
    100% {
        left: 150%;
    }
}

/* 2. AI Chat Window Container - Luxury White-to-Cream Soft Gradient */
.ai-chat-window {
    position: fixed;
    right: 25px;
    bottom: 95px;
    width: 320px;
    height: 480px;
    min-width: 320px;
    min-height: 400px;
    border-radius: 24px;
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16), 0 0 25px rgba(255, 90, 31, 0.25);
    border: 2px solid #FF5A1F !important;
    background: linear-gradient(135deg, #FFFFFF 0%, #FFF8F5 100%) !important;
    color: #1F2937 !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', 'Poppins', sans-serif;
    animation: ai-window-glow 4s infinite alternate ease-in-out !important; /* AI breathing neon glow */
}

/* Dark Mode Override */
.ai-chat-window.ai-dark-mode {
    background: linear-gradient(135deg, #FFFFFF 0%, #FFF8F5 100%) !important;
    border: 2px solid #FF5A1F !important;
    color: #1F2937 !important;
}

/* Resize Handler (Top-Left corner drag resizer) */
.ai-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    width: 15px;
    height: 15px;
    cursor: nwse-resize;
    z-index: 10001;
}

.ai-chat-header {
    background: linear-gradient(135deg, #E8251A 0%, #FF5A1F 100%) !important;
    padding: 10px 12px !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
    cursor: move;
    user-select: none;
    box-shadow: 0 4px 15px rgba(232, 37, 26, 0.3);
    position: relative !important;
    overflow: hidden !important; /* Contain header shimmer */
}
.ai-chat-header::before {
    content: '' !important;
    position: absolute !important;
    top: -50% !important;
    left: -150% !important;
    width: 200% !important;
    height: 200% !important;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.2) 30%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0.2) 70%,
        rgba(255, 255, 255, 0) 100%
    ) !important;
    transform: rotate(30deg) !important;
    animation: ai-shimmer-header 4s infinite ease-in-out !important;
    pointer-events: none !important;
    z-index: 5 !important;
}
.ai-chat-header-title {
    display: flex;
    align-items: center;
    font-weight: 800;
    font-size: 14px !important;
    color: #FFFFFF !important;
    letter-spacing: 0.3px;
}
.ai-chat-header-actions {
    display: flex;
    gap: 4px !important;
    align-items: center;
}
.ai-chat-header-actions button {
    background: #FFFFFF !important;
    border: none !important;
    border-radius: 50%;
    width: 26px !important;
    height: 26px !important;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #E8251A !important;
    font-size: 11px !important;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ai-chat-header-actions button:hover {
    background: #FFF8F5 !important;
    color: #FF5A1F !important;
    transform: scale(1.1);
}

/* 4. Chat Body / Messages list */
.ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Message Bubble structure */
.ai-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: ai-slide-up 0.3s ease;
}
@keyframes ai-slide-up {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.ai-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.ai-message-user .ai-bubble {
    background: linear-gradient(135deg, #E8251A, #FF5A1F) !important;
    color: #FFFFFF !important;
    border-radius: 18px 18px 4px 18px !important;
    box-shadow: 0 4px 14px rgba(232, 37, 26, 0.25) !important;
}
.ai-message-bot .ai-bubble {
    background: #FFFFFF !important;
    color: #1F2937 !important;
    border: 1px solid #E2E8F0 !important;
    border-left: 4px solid #E8251A !important;
    border-radius: 18px 18px 18px 4px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05) !important;
}

/* Bot bubble under Dark Mode (Maintained White & Red) */
.ai-dark-mode .ai-message-bot .ai-bubble {
    background: #FFFFFF !important;
    color: #1F2937 !important;
    border-left: 4px solid #E8251A !important;
}

/* Inside message helper actions (speaker, copy, download, share) */
.ai-bubble-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.ai-message:hover .ai-bubble-actions {
    opacity: 0.75;
}
.ai-bubble-actions button {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}
.ai-bubble-actions button:hover {
    background: rgba(0, 0, 0, 0.05);
}
.ai-dark-mode .ai-bubble-actions button:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Related citation card link lists */
.ai-related-container {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-related-card {
    background: rgba(255, 90, 31, 0.05);
    border: 1px dashed rgba(255, 90, 31, 0.3);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    text-decoration: none !important;
    color: inherit !important;
}
.ai-related-card:hover {
    background: rgba(255, 90, 31, 0.1);
}
.ai-related-card-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}
.ai-related-card-badge {
    background: var(--ai-primary);
    color: #fff;
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 50px;
}

/* 5. Input Console Block */
.ai-chat-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 90, 31, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ai-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-input-wrapper input {
    flex: 1;
    min-width: 0 !important;
    border: 1.5px solid rgba(255, 90, 31, 0.15);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    padding: 10px 18px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}
.ai-input-wrapper input:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 10px rgba(255, 90, 31, 0.1);
}
.ai-dark-mode .ai-input-wrapper input {
    background: rgba(31, 41, 55, 0.8);
    border-color: rgba(255, 90, 31, 0.3);
    color: var(--ai-text-dark);
}

.ai-footer-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
}
.ai-btn-attach {
    background: rgba(0, 0, 0, 0.05);
    color: #6b7280;
}
.ai-btn-voice {
    background: rgba(0, 0, 0, 0.05);
    color: #ef4444;
}
.ai-btn-send {
    background: var(--ai-primary);
    color: #ffffff;
}
.ai-footer-btn:hover {
    transform: scale(1.08);
}

/* File Attachment Preview */
.ai-preview-attachment {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 90, 31, 0.08);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
}
.ai-preview-attachment-remove {
    cursor: pointer;
    color: #ef4444;
}

/* Typing Indicator Animation */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    align-items: center;
}
.ai-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--ai-primary);
    border-radius: 50%;
    animation: ai-bounce 1.4s infinite ease-in-out both;
}
.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes ai-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Voice Wave Visualizer */
.ai-voice-active {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 20px;
}
.ai-voice-bar {
    width: 3px;
    height: 100%;
    background: var(--ai-primary);
    animation: ai-wave 1s ease-in-out infinite alternate;
}
.ai-voice-bar:nth-child(2) { animation-delay: 0.1s; }
.ai-voice-bar:nth-child(3) { animation-delay: 0.2s; }
.ai-voice-bar:nth-child(4) { animation-delay: 0.3s; }
@keyframes ai-wave {
    0% { height: 4px; }
    100% { height: 18px; }
}

/* Mobile & Tablet Responsiveness for AI Launcher Button */
@media (max-width: 991px) {
    .ai-launcher-btn {
        bottom: 85px !important;
    }
}

/* 6. Mobile Responsiveness */
@media (max-width: 768px) {
    .ai-chat-window {
        right: 5% !important;
        bottom: 85px !important;
        width: 90% !important;
        height: 70vh !important;
        max-width: 90% !important;
        max-height: 70vh !important;
        border-radius: 16px !important;
        border: 2px solid #FF5A1F !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
    }
    .ai-resize-handle {
        display: none !important;
    }
    .ai-chat-header {
        cursor: default !important;
        border-radius: 0 !important;
    }
}

/* 7. Voice & Language Settings Panel */
.ai-settings-panel {
    background: rgba(17, 24, 39, 0.96);
    border-bottom: 1px solid rgba(255, 90, 31, 0.25);
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: all 0.3s ease;
}
.ai-settings-label {
    display: block;
    font-size: 0.72rem;
    color: #a0aec0;
    font-weight: 600;
    margin-bottom: 3px;
    text-transform: uppercase;
}
.ai-settings-panel select, .ai-settings-panel input {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    color: #fff !important;
    font-size: 0.8rem !important;
}
.ai-settings-panel select option {
    background: #111827 !important;
    color: #fff !important;
}
.ai-settings-panel .form-range {
    height: 1.2rem;
    padding: 0;
    background: transparent !important;
    border: none !important;
}

/* 8. Voice Player Control Bar */
.ai-voice-player {
    z-index: 99;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ai-player-btn {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ai-player-btn:hover {
    color: var(--ai-primary);
    background: rgba(255, 90, 31, 0.1);
    transform: scale(1.1);
}
.ai-player-btn:active {
    transform: scale(0.95);
}

/* Currently reading paragraph highlight */
.ai-reading-highlight {
    background: rgba(255, 90, 31, 0.12) !important;
    border-left: 3px solid var(--ai-primary) !important;
    padding-left: 8px !important;
    border-radius: 4px;
    transition: background 0.3s ease, border-left 0.3s ease;
}

/* Pulsing header logo indicator */
.ai-chat-header-title img {
    animation: ai-pulse-logo 2.5s infinite ease-in-out !important;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5) !important;
    transition: all 0.3s ease !important;
}
.ai-chat-header-title img:hover {
    transform: scale(1.1) rotate(10deg) !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.9) !important;
}
@keyframes ai-pulse-logo {
    0%, 100% {
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.5) !important;
        border-color: rgba(255, 255, 255, 0.6) !important;
    }
    50% {
        box-shadow: 0 0 16px rgba(255, 255, 255, 0.9), 0 0 8px rgba(255, 90, 31, 0.6) !important;
        border-color: rgba(255, 255, 255, 1) !important;
    }
}

/* AI Breathing Neon Window Outline Glow */
@keyframes ai-window-glow {
    0% {
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16), 0 0 15px rgba(255, 90, 31, 0.2) !important;
        border-color: #FF5A1F !important;
    }
    100% {
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2), 0 0 30px rgba(255, 90, 31, 0.45), 0 0 10px rgba(255, 45, 85, 0.3) !important;
        border-color: #FF2D55 !important;
    }
}

@keyframes ai-shimmer-header {
    0% {
        left: -150%;
    }
    25% {
        left: 150%;
    }
    100% {
        left: 150%;
    }
}

