/* =========================================
   Variables & Configuration
   ========================================= */
:root {
    /* Colors aligned with global theme */
    --accent: #50e3c2;
    --accent-hover: #3bc7a9;
    --bg-dark: #0a0f1a;
    
    --card-bg: rgba(15, 23, 42, 0.65);
    --card-border: rgba(255, 255, 255, 0.1);
    
    --text-main: #f7fbff;
    --text-muted: rgba(247, 251, 255, 0.75);
    
    --header-height: 70px;
    --radius-lg: 16px;
    --radius-md: 10px;
}

/* =========================================
   Page Layout
   ========================================= */
.faq-page {
    padding: calc(var(--header-height) + 2rem) 1.5rem 6rem; /* Extra padding bottom for chat button */
    min-height: 80vh;
    width: 100%;
    position: relative;
    z-index: 2; /* Ensure content sits above particles */
}

.faq-page .container {
    max-width: 1000px;
    margin: 0 auto;
}

.page-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.lead {
    color: var(--text-muted);
    margin-bottom: 3rem;
    font-size: 1.15rem;
    line-height: 1.6;
    max-width: 650px;
}

/* =========================================
   FAQ Grid & Items
   ========================================= */
.faq-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); /* Smart responsiveness */
    gap: 1.25rem;
    margin-bottom: 3rem;
}

.faq-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.faq-item:hover {
    border-color: rgba(80, 227, 194, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

/* The Question Button */
.faq-toggle {
    width: 100%;
    background: transparent;
    border: 0;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    text-align: left;
    outline: none;
    transition: background 0.2s ease;
}

.faq-q {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
    line-height: 1.4;
}

.faq-toggle:focus-visible {
    background: rgba(255,255,255,0.03);
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* The Caret Icon */
.faq-caret {
    color: var(--accent);
    font-size: 1.2rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

/* State: Open */
.faq-toggle[aria-expanded="true"] .faq-caret {
    transform: rotate(90deg);
}

.faq-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.04);
}

/* The Answer */
.faq-answer {
    padding: 0 1.5rem 1.5rem 1.5rem;
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 0.95rem;
    border-top: 1px solid transparent;
}

.faq-answer:not([hidden]) {
    animation: fadeIn 0.3s ease;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 1rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   Quick Help / Chips
   ========================================= */
.faq-help {
    margin-top: 2rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.faq-help h3 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin: 0;
}

.faq-chips {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.chip:hover {
    background: rgba(80, 227, 194, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

/* =========================================
   Chat Widget
   ========================================= */
.faq-chat {
    position: fixed;
    right: 24px;
    bottom: 90px; /* Above the toggle button */
    width: 380px;
    max-width: calc(100% - 48px);
    height: 500px; /* Fixed height for consistency */
    max-height: 70vh;
    background: rgba(10, 15, 30, 0.95);
    border-radius: 18px;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    z-index: 1300; 
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform-origin: bottom right;
    animation: slideInChat 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInChat {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.faq-chat .chat-header {
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chat-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
    border-radius: 4px;
}
.chat-header button:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* Messages Area */
.chat-messages {
    padding: 1rem;
    flex: 1; /* Fills remaining space */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

/* Avatar Row Layout */
.chat-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end; /* Align avatar to bottom of message */
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-dark);
    border: 1px solid var(--card-border);
}

.chat-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: calc(100% - 48px);
}

.chat-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 0.2rem;
    font-weight: 600;
}

/* Message Bubbles */
.chat-msg {
    padding: 0.7rem 1rem;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 0.95rem;
    position: relative;
    word-wrap: break-word;
    border-bottom-left-radius: 2px; /* Chat bubble style */
}

/* User Specifics */
.chat-row:has(.user) {
    flex-direction: row-reverse; /* Flip user messages */
}

.chat-row:has(.user) .chat-content {
    align-items: flex-end;
}

.chat-msg.user {
    background: linear-gradient(135deg, var(--accent), #3bbcb8);
    color: #08101c;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 2px;
    box-shadow: 0 4px 12px rgba(80, 227, 194, 0.2);
}

/* Bot Specifics */
.chat-msg.bot {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Typing Indicator Animation */
.chat-msg.typing {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0.8rem 1rem;
    min-width: 50px;
}

.dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
    opacity: 0.7;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Input Area */
.chat-form {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-form input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.chat-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}

.chat-form .btn {
    padding: 0 1.25rem;
    border-radius: 99px;
    background: var(--accent);
    color: #08101c;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
}

.chat-form .btn:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

/* Chat Toggle Button (Floating) */
#chat-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1201;
    padding: 0.8rem 1.5rem;
    border-radius: 99px;
    background: linear-gradient(135deg, var(--accent), #3bbcb8);
    box-shadow: 0 8px 20px rgba(80, 227, 194, 0.3);
    color: #08101c;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#chat-toggle:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 25px rgba(80, 227, 194, 0.5);
}

/* =========================================
   Responsiveness
   ========================================= */
@media (max-width: 880px) {
    .faq-page {
        padding-top: calc(var(--header-height) + 1rem);
    }
    
    .faq-list {
        grid-template-columns: 1fr; /* Single column on tablet/mobile */
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .faq-page {
        padding: calc(var(--header-height) + 1rem) 1rem 5rem;
    }

    .page-title {
        font-size: 2rem;
    }

    /* Chat takes full width/height on mobile, but keeps header visible */
    .faq-chat {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 60vh;
        border-radius: 20px 20px 0 0; /* Only top corners rounded */
        animation: slideUpMobile 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    @keyframes slideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    #chat-toggle {
        bottom: 20px;
        right: 20px;
        padding: 0.7rem 1.2rem;
    }
}