/**
 * FLOSC App Layout (v1.4.6) — Ultra Pro Edition
 * ==============================================
 * Updated: 2026-02m-06d
 * 
 * LAYOUT ONLY — No colors, no theme styles.
 * All visual styling comes from flosc-theme.css + chat-style-*.css presets.
 * 
 * ARCHITECTURE:
 * 1. flosc-layout.css  — Structure, positioning, flexbox (this file)
 * 2. flosc-theme.css   — Variable consumption, theming
 * 3. chat-style-*.css  — Variable definitions (light/dark/claude/chatgpt/grok)
 * 
 * BACKWARD COMPATIBILITY:
 * Supports both legacy class names and new flosc- prefixed names.
 * Legacy selectors are grouped with new selectors using CSS commas.
 * 
 * ============================================================================
 * ⚠️  HARD-LEARNED LESSON: SVG ICON VISIBILITY (2026-01m-25d)
 * ============================================================================
 * AI tools repeatedly broke icon visibility by adding incorrect CSS rules.
 * After 6+ failed AI attempts and hours of debugging, here's what works:
 * 
 * THE PATTERN THAT WORKS:
 * ┌─────────────────────────────────────────────────────────────────────────┐
 * │  HTML (in flosc-app.php):                                               │
 * │  <button class="my-button">                                             │
 * │      <svg fill="none" stroke="currentColor" stroke-width="2">          │
 * │          <path d="..."></path>                                          │
 * │      </svg>                                                              │
 * │  </button>                                                               │
 * ├─────────────────────────────────────────────────────────────────────────┤
 * │  CSS Layout (this file):                                                │
 * │  .my-button { display: flex; align-items: center; ... }                 │
 * │  .my-button svg { width: 20px; height: 20px; display: block; }          │
 * ├─────────────────────────────────────────────────────────────────────────┤
 * │  CSS Theme (flosc-theme.css):                                           │
 * │  .my-button { color: var(--some-color); }  -- EXPLICIT color --        │
 * │  .my-button:hover { color: var(--hover-color); }                        │
 * └─────────────────────────────────────────────────────────────────────────┘
 * 
 * WHY THIS WORKS:
 * - stroke="currentColor" makes SVG inherit color from parent element
 * - Parent button MUST have explicit color (not inherit/initial/unset)
 * - display: block on SVG prevents inline whitespace issues
 * - Hover on button changes color, SVG automatically updates
 * 
 * WHAT BREAKS IT (AI kept doing these):
 * ✗ Adding stroke: currentColor in CSS (already in HTML, causes specificity wars)
 * ✗ Using fill instead of stroke for line-art icons
 * ✗ Omitting color on button and relying on inheritance
 * ✗ Adding !important everywhere (masks the real problem)
 * ✗ Inline styles to "fix" visibility (breaks theming)
 * 
 * ============================================================================
 */

/* ============================================
   RESET & BASE
   ============================================ */

/* v1.6.1: Scoped to .flosc-app to avoid WordPress theme collisions */
.flosc-app, .flosc-app *, .flosc-app *::before, .flosc-app *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* v1.6.9: Lock viewport so nothing overflows below screen edge */
html, body {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.flosc-app {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* v1.7.6: Chat scale via admin setting (--flosc-scale set in body style attribute)
 * Scales the chat messages area and composer — NOT the sidebar or header,
 * which should remain a fixed, predictable size. */
.flosc-messages,
.messages {
    font-size: calc(15px * var(--flosc-scale, 100%) / 100);
}

.flosc-input-composer,
.flosc_input_composer {
    font-size: calc(15px * var(--flosc-scale, 100%) / 100);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.flosc-hidden {
    display: none !important;
}

.flosc-visible {
    display: block !important;
}

/* ============================================
   APP CONTAINER
   ============================================ */

.flosc-app {
    display: flex;
    height: 100vh;
    height: 100dvh; /* v1.8.2: dynamic viewport height — handles Safari toolbar correctly */
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

/* v1.7.0: Account for WordPress admin bar (32px desktop, 46px mobile) */
.admin-bar .flosc-app,
.admin-bar.flosc-app {
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar .flosc-app,
    .admin-bar.flosc-app {
        height: calc(100vh - 46px);
        height: calc(100dvh - 46px);
        max-height: calc(100vh - 46px);
        max-height: calc(100dvh - 46px);
    }
}

/* ============================================
   SIDEBAR
   ============================================ */

.flosc-sidebar {
    width: 280px;
    height: 100%;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    /* v1.8.2: Safe-area bottom padding so profile bar isn't clipped on notched devices */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* v1.9.5: Desktop sidebar collapse — full hide (Grok pattern).
   Sidebar transitions to 0px width; overflow: hidden clips all content.
   Header's mobile-menu-btn becomes visible to reopen sidebar. */
.flosc-sidebar.collapsed {
    width: 0;
    padding-bottom: 0;
    border: none;
}

/* Header: hide logo text, keep only toggle button centered */
.flosc-sidebar.collapsed .sidebar-header {
    padding: 12px 8px;
    justify-content: center;
}

.flosc-sidebar.collapsed .logo {
    display: none;
}

.flosc-sidebar.collapsed .sidebar-header-actions {
    width: 100%;
    justify-content: center;
}

/* Hide restart button when collapsed — only toggle visible */
.flosc-sidebar.collapsed .sidebar-action-btn {
    display: none;
}

/* New Chat: icon-only, centered */
.flosc-sidebar.collapsed .new-chat-btn {
    margin: 4px 8px;
    padding: 10px;
    justify-content: center;
}

.flosc-sidebar.collapsed .new-chat-btn span {
    display: none;
}

/* Session list: hide text, show only icons */
.flosc-sidebar.collapsed .flosc_app_session_list {
    padding: 4px;
}

.flosc-sidebar.collapsed .session-group-title {
    display: none;
}

.flosc-sidebar.collapsed .session-item {
    padding: 10px 0;
    justify-content: center;
}

.flosc-sidebar.collapsed .session-item-title {
    display: none;
}

.flosc-sidebar.collapsed .session-item-actions {
    display: none !important;
}

/* Profile bar: avatar-only, centered */
.flosc-sidebar.collapsed .user-profile-bar {
    padding: 4px;
}

.flosc-sidebar.collapsed .profile-button {
    padding: 8px 0;
    justify-content: center;
}

.flosc-sidebar.collapsed .profile-info {
    display: none;
}

.flosc-sidebar.collapsed .dropdown-icon {
    display: none;
}

/* v1.9.5: When sidebar is 0px, dropdown is unreachable — user reopens sidebar first */
.flosc-sidebar.collapsed .profile-dropdown {
    display: none;
}

/* Sidebar Header */
.flosc-sidebar-header,
.flosc-sidebar .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    min-height: 56px;
}

/* Sidebar Logo */
.flosc-sidebar-logo,
.flosc-sidebar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 18px;
}

.flosc-sidebar-logo-emoji,
.flosc-sidebar .logo-emoji {
    font-size: 24px;
}

.flosc-sidebar .logo-text {
    font-weight: 600;
}

.flosc-sidebar .logo-img {
    height: 32px;
    width: auto;
}

/* Sidebar Header Actions */
.flosc-sidebar-actions,
.flosc-sidebar .sidebar-header-actions {
    display: flex;
    gap: 4px;
}

/* Sidebar Action Buttons
 * ICON BUTTON PATTERN — see header comment for SVG lesson.
 */
.flosc-sidebar-action-btn,
.flosc-sidebar .sidebar-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #667;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.flosc-sidebar-action-btn svg,
.flosc-sidebar .sidebar-action-btn svg {
    width: 18px;
    height: 18px;
    display: block; /* CRITICAL: prevents inline whitespace issues */
}

/* Animation: Spin for restart button */
.flosc-sidebar-action-btn.spinning svg,
.flosc-sidebar .sidebar-action-btn.spinning svg {
    animation: spin 0.6s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Sidebar Close/Toggle Button */
.flosc-sidebar-toggle,
.flosc_app_sidebar_toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.flosc_app_sidebar_toggle svg {
    width: 20px;
    height: 20px;
    display: block;
    stroke: #6b7280;
    stroke-width: 2;
    fill: none;
}

.flosc_app_sidebar_toggle:hover svg {
    stroke: #374151;
}

/* New Chat Button */
.flosc-new-chat-btn,
.flosc-sidebar .new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 16px;
    padding: 11px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

/* ============================================
   SESSION LIST
   ============================================ */

.flosc-session-list,
.flosc_app_session_list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.flosc-session-group {
    margin-bottom: 16px;
}

.flosc-session-group-title,
.session-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 12px 4px;
}

.flosc-session-item,
.session-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s ease;
}

.flosc-session-item-icon,
.session-item-icon {
    font-size: 16px;
}

.flosc-session-item-title,
.session-item-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flosc-session-item-actions,
.session-item-actions {
    display: none;
    gap: 4px;
}

.flosc-session-item:hover .flosc-session-item-actions,
.flosc-session-item:hover .session-item-actions,
.session-item:hover .session-item-actions {
    display: flex;
}

/* ============================================
   USER PROFILE BAR
   One bar, 3 states: visitor | guest | member
   Content toggled via [data-show] + [data-user-state]
   ============================================ */

.flosc_app_session_list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.user-profile-bar {
    margin-top: auto; /* push to bottom of sidebar flex column */
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    display: flex;
    flex-direction: column;
    position: relative;
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    /* v1.8.2: Prevent avatar (36px) from being clipped by sidebar overflow:hidden */
    min-height: 70px;
}

/* data-show visibility: visitor content vs logged-in content */
[data-user-state="visitor"] [data-show="logged-in"],
[data-user-state="guest"] [data-show="visitor"],
[data-user-state="member"] [data-show="visitor"] {
    display: none !important;
}

/* v1.8.4: Use display:block (not display:initial) so <img> elements
   render as block instead of inline. display:initial resolves to
   inline for <img>, which breaks flex sizing of the avatar. */
[data-user-state="visitor"] [data-show="visitor"],
[data-user-state="guest"] [data-show="logged-in"],
[data-user-state="member"] [data-show="logged-in"] {
    display: block;
}

/* Upgrade container: guest only */
[data-user-state="member"] .upgrade-container {
    display: none !important;
}

.user-profile-bar .profile-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
    transition: background 0.15s ease;
}

/* v1.8.3: Avatar shape controlled by CSS custom properties set in admin UI
   --flosc-avatar-width   (default 36px) — rectangle support
   --flosc-avatar-height  (default 36px) — rectangle support
   --flosc-avatar-radius  (default 50%) — 50%=circle, 8px=rounded, 0=sharp */
.flosc-profile-avatar,
.flosc-user-avatar,
.profile-avatar {
    width: var(--flosc-avatar-width, 36px);
    height: var(--flosc-avatar-height, 36px);
    min-width: var(--flosc-avatar-width, 36px);
    min-height: var(--flosc-avatar-height, 36px);
    border-radius: var(--flosc-avatar-radius, 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    object-fit: cover;
    flex-shrink: 0;
}

/* v1.8.4: Bulletproof avatar sizing — !important beats any WordPress
   theme rule (e.g. img{max-width:100%;height:auto}). The flosc-app
   prefix scopes this to FLOSC only; won't leak to other page images. */
.flosc-app .flosc-profile-avatar {
    width: var(--flosc-avatar-width, 36px) !important;
    height: var(--flosc-avatar-height, 36px) !important;
    min-width: var(--flosc-avatar-width, 36px) !important;
    min-height: var(--flosc-avatar-height, 36px) !important;
    max-width: var(--flosc-avatar-width, 36px) !important;
    max-height: var(--flosc-avatar-height, 36px) !important;
    border-radius: var(--flosc-avatar-radius, 50%) !important;
    object-fit: cover !important;
    flex-shrink: 0;
}

/* v1.8.4: img avatars must be display:block (not flex — img is replaced
   content). !important needed to beat the data-show display:block rule
   which could be overridden by theme specificity chains. */
img.flosc-profile-avatar {
    display: block !important;
}

.flosc-profile-avatar.visitor-avatar,
.profile-avatar.visitor-avatar {
    background: transparent;
    font-size: 20px;
}

.flosc-user-info,
.profile-info {
    flex: 1;
    min-width: 0;
}

.flosc-user-name,
.profile-name {
    font-weight: 500;
    font-size: 14px;
}

.flosc-user-email,
.profile-badge {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.7;
}

/* Dropdown icon styling */
.profile-button .dropdown-icon {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.profile-button:hover .dropdown-icon {
    opacity: 0.8;
}

.profile-dropdown.open ~ .profile-button .dropdown-icon,
.profile-button[aria-expanded="true"] .dropdown-icon {
    transform: rotate(180deg);
}

/* Profile Dropdown */
.profile-dropdown {
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    margin-bottom: 8px;
    border-radius: 12px;
    overflow: hidden;
    display: none;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.profile-dropdown.open {
    display: block;
    animation: dropdownIn 0.15s ease;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown-header {
    padding: 12px 16px;
}

.dropdown-name {
    font-weight: 500;
    font-size: 14px;
}

.dropdown-email {
    font-size: 12px;
}

.profile-dropdown-item {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    text-decoration: none;
}

.upgrade-container {
    padding: 8px 16px 16px;
}

.upgrade-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.flosc-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* ============================================
   HEADER
   ============================================ */

.flosc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    height: 48px;
}

.flosc-header-title,
.header-title {
    font-size: 16px;
    font-weight: 600;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--flosc-text-primary, #374151);
}

.mobile-menu-btn svg {
    stroke: currentColor;
}

/* v1.8.0: Only show hamburger + mobile logo on mobile when sidebar is hidden */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }
}

/* v1.9.5: When sidebar is collapsed to 0px (Grok pattern), show hamburger + mobile logo
   in the header so user can reopen sidebar from the main content area. */
.flosc-sidebar.collapsed ~ .flosc-main .mobile-menu-btn {
    display: flex;
}
.flosc-sidebar.collapsed ~ .flosc-main .logo-mobile {
    display: flex;
}

/* v1.8.0: Hide mobile logo on desktop (sidebar already shows branding) */
.logo-mobile {
    display: none;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .logo-mobile {
        display: flex;
    }
}

.auth-buttons {
    display: flex;
    gap: 8px;
}

.flosc-share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

/* ============================================
   CHAT CONTAINER
   ============================================ */

.flosc-chat-container,
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ============================================
   VISITOR BAR (v1.7.9)
   ============================================ */

.flosc-visitor-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    border-bottom: 1px solid var(--flosc-visitor-bar-border, #bfdbfe);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideDown 0.3s ease-out;
}

.flosc-visitor-bar-content {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 800px;
    width: 100%;
}

.flosc-visitor-bar-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.flosc-visitor-bar-cta {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.flosc-visitor-bar-cta:hover {
    opacity: 0.9;
}

.flosc-visitor-bar-dismiss {
    padding: 4px 8px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.flosc-visitor-bar-dismiss:hover {
    opacity: 1;
}

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

/* Mobile adjustments */
@media (max-width: 600px) {
    .flosc-visitor-bar-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .flosc-visitor-bar-text {
        text-align: center;
    }

    .flosc-visitor-bar-dismiss {
        position: absolute;
        top: 8px;
        right: 8px;
    }
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.flosc-messages,
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.flosc-messages-inner,
.messages-inner {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

/* v1.9.5: Messages area — always flex:1 for stable layout.
   Landing state collapses via flosc-hidden when user sends first message. */

/* ============================================
   GREETING / WELCOME
   ============================================ */

.flosc-greeting,
.greeting {
    text-align: center;
    padding: 16px 24px 12px;
}

.flosc-greeting-emoji,
.greeting-emoji {
    font-size: 32px;
    margin-bottom: 8px;
}

.flosc-greeting-title,
.greeting-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.03em;
}

.flosc-greeting-subtitle,
.greeting-subtitle {
    font-size: 15px;
    line-height: 1.6;
}

/* v1.9.5: Landing state — compact centered identity block.
   Vertically centered when no messages. Hidden when user sends first message.
   Layout: [icon] FLOSC  tagline  (one line)
           Freeline → Login → Offer → Sale → Content  (below) */
.landing-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    gap: 12px;
    padding: 24px;
    transition: opacity 0.2s ease;
}

/* When messages exist alongside, landing state shrinks to content height
   and sits at top instead of competing for 50% of the viewport. */
.chat-container:has(.messages .message) .landing-state {
    flex: 0 0 auto;
    justify-content: flex-start;
    padding: 16px 24px 8px;
}

.landing-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.landing-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}

.landing-emoji {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

.landing-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.landing-subtitle {
    font-size: 14px;
    opacity: 0.6;
    white-space: nowrap;
}

.landing-tagline {
    font-size: 12px;
    letter-spacing: 0.5px;
    opacity: 0.35;
}

/* ============================================
   MESSAGE ROW
   ============================================ */

.flosc-message,
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
    width: 100%;
    animation: messageIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.flosc-message-user,
.message.user {
    flex-direction: row-reverse;
}

/* ============================================
   MESSAGE AVATAR
   ============================================ */

.flosc-message-avatar,
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   MESSAGE CONTENT
   ============================================ */

/* v1.9.5: Assistant messages use full column width (Grok pattern).
   User messages constrained to 75% via user-specific rule below.
   v2.0.4: flex-grow:1 ensures content stretches to fill available width
   so centered elements (badge) center relative to the full chat area. */
.flosc-message-content,
.message-content {
    max-width: 100%;
    min-width: 0;
    flex-grow: 1;
}

/* v1.7.5: Rich cards expand full width within chat area */
.message-content:has(.flosc-quiz-result),
.message-content:has(.flosc-sandbox-payment),
.message-content:has(.flosc-quiz-gate),
.message-content:has(.flosc-sandbox-success),
.message-content:has(.flosc-offer-card),
.message-content:has(.flosc-offer-featured),
.message-content:has(.flosc-offer-banner),
.message-content:has(.flosc-offer-compact),
.message-content:has(.flosc-checkout-inline),
.message-content:has(.flosc-quiz-question),
.flosc-message-content:has(.flosc-quiz-result),
.flosc-message-content:has(.flosc-sandbox-payment),
.flosc-message-content:has(.flosc-quiz-gate),
.flosc-message-content:has(.flosc-sandbox-success),
.flosc-message-content:has(.flosc-offer-card),
.flosc-message-content:has(.flosc-offer-featured),
.flosc-message-content:has(.flosc-offer-banner),
.flosc-message-content:has(.flosc-offer-compact),
.flosc-message-content:has(.flosc-checkout-inline),
.flosc-message-content:has(.flosc-quiz-question) {
    max-width: 100%;
}

.flosc-message-user .flosc-message-content,
.flosc-message-user .message-content,
.message.user .message-content {
    max-width: 75%;
    text-align: right;
}

/* ============================================
   MESSAGE TEXT (Bubble)
   ============================================ */

.flosc-message-text,
.message-text {
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
    letter-spacing: -0.006em;
    /* v2.0.5: Ensure full width so centered badge images align to
       the full message area, not just the text content width. */
    width: 100%;
}

.flosc-message-user .flosc-message-text,
.flosc-message-user .message-text,
.message.user .message-text {
    display: inline-block;
    text-align: left;
    padding: 12px 18px;
    border-radius: 20px 20px 4px 20px;
}

.flosc-message-text p,
.message-text p {
    margin-bottom: 14px;
}

.flosc-message-text p:last-child,
.message-text p:last-child {
    margin-bottom: 0;
}

.flosc-message-text ul,
.flosc-message-text ol,
.message-text ul,
.message-text ol {
    margin: 14px 0;
    padding-left: 24px;
}

.flosc-message-text li,
.message-text li {
    margin-bottom: 6px;
    line-height: 1.6;
}

.flosc-message-text code,
.message-text code {
    font-size: 0.88em;
    padding: 2px 7px;
    border-radius: 5px;
    font-family: 'SF Mono', 'JetBrains Mono', Monaco, 'Courier New', monospace;
}

.flosc-message-text pre,
.message-text pre {
    margin: 14px 0;
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
}

.flosc-message-text pre code,
.message-text pre code {
    padding: 0;
    background: none;
}

/* ============================================
   INPUT COMPOSER
   ============================================ */

/* v2.0.1: Reduced top padding to tighten gap with AutoPromptPanel */
.flosc-input-composer,
.flosc_input_composer {
    padding: 8px 24px 16px;
}

.flosc-input-composer-inner,
.flosc_input_composer_inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.flosc-input-field,
.flosc_input_composer textarea,
#flosc_input_chat_field {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    font-size: 15px;
    line-height: 1.5;
    max-height: 150px;
    min-height: 24px;
    font-family: inherit;
    letter-spacing: -0.006em;
}

.flosc-send-btn,
.flosc_input_chat_send_button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.flosc_input_chat_send_button svg {
    width: 20px;
    height: 20px;
    display: block;
}

.flosc_input_chat_voice_button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.flosc_input_chat_voice_button svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* ============================================
   USER AUTOPROMPTS / PILLS & CARDS
   ============================================ */

/* v2.0.2: Tighter vertical spacing — reduced padding and gap */
.flosc-user-autoprompts,
.flosc-user-autoprompts-container,
#flosc_input_user_autoprompts_panel {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 24px 4px;
    max-width: 800px;
    margin: 0 auto;
    justify-content: center;
}

/* v2.0.2: Slightly tighter pills */
.flosc-pill,
.flosc-style-pill {
    padding: 6px 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-height: 56px;
}

.flosc-card,
.flosc-style-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 14px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    overflow: hidden;
    word-break: break-word;
    /* v2.0.1: Clamp long text to 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    line-clamp: 4;
}

/* v1.6.5: Button (CTA-style) layout */
.flosc-style-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

/* Prompt Panel (Inline) */
/* v2.0.2: Tighter panel — reduce vertical padding */
.prompt-panel {
    padding: 4px 16px;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.prompt-panel-inline {
    max-width: 800px;
    margin: 0 auto;
}

/* v1.7.0: Ensure carousel container respects parent width */
.prompt-panel .flosc-carousel-container {
    max-width: 100%;
}

.prompt-panel .flosc-carousel-track {
    overflow: hidden;
}

/* ============================================
   CAROUSEL (for user autoprompts)
   ============================================ */

.flosc-carousel-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    overflow: hidden;
}

.flosc-carousel-track {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 0;          /* v1.7.0: CRITICAL — allows flex item to shrink below content width */
    padding: 4px 0;
    overflow: hidden;       /* v1.7.0: clip pills during translateX carousel animation */
}

/* Pills container inside carousel track */
.flosc-carousel-track.flosc-pills-container {
    flex-wrap: nowrap;
    justify-content: flex-start;
}

/* Pills don't shrink in carousel */
.flosc-carousel-track.flosc-pills-container .flosc-style-pill {
    flex-shrink: 0;
}

/* Cards container inside carousel track */
.flosc-carousel-track.flosc-cards-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
}

/* Fixed width cards in carousel */
.flosc-carousel-track.flosc-cards-container .flosc-style-card {
    flex-shrink: 0;
    width: 180px;
    min-width: 180px;
}

.flosc-carousel-track::-webkit-scrollbar {
    display: none;
}

/* Carousel Arrows — hidden by default, shown on overflow */
.flosc-carousel-arrow {
    display: none;
    background: white;
    border: 1px solid var(--flosc-border-color, #e5e7eb);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: var(--flosc-text-secondary, #6b7280);
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 0;
    line-height: 1;
}

/* Show arrows when container has overflow (set by JS) */
.flosc-carousel-container.has-overflow .flosc-carousel-arrow {
    display: flex;
}

.flosc-carousel-arrow:hover {
    background: var(--flosc-bg-hover, #f3f4f6);
    border-color: var(--flosc-primary, #4f46e5);
    color: var(--flosc-primary, #4f46e5);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.flosc-carousel-arrow:active {
    opacity: 0.8;
}

/* Pills container (standalone, no carousel) */
.flosc-pills-container:not(.flosc-carousel-track) {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    justify-content: flex-start;
}

/* Cards container (standalone) */
.flosc-cards-container:not(.flosc-carousel-track) {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 14px;
    width: 100%;
}

@media (max-width: 768px) {
    .flosc-carousel-arrow {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .flosc-carousel-container {
        gap: 8px;
    }
    
    /* Stack cards on mobile */
    .flosc-carousel-track.flosc-cards-container,
    .flosc-cards-container:not(.flosc-carousel-track) {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.flosc-typing-indicator,
.typing-indicator {
    display: none;
    gap: 12px;
    padding: 0 24px;
    margin-bottom: 22px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    align-items: flex-start;
}

.flosc-typing-indicator.show,
.typing-indicator.show {
    display: flex;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.flosc-typing-dots,
.typing-dots {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}

.flosc-typing-dot,
.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: flosc-typing 1.4s infinite;
}

.flosc-typing-dot:nth-child(2),
.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.flosc-typing-dot:nth-child(3),
.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes flosc-typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ============================================
   RESPONSIVE — TABLET (1024px)
   ============================================ */

@media (max-width: 1024px) {
    .flosc-sidebar {
        width: 260px;
    }
}

/* ============================================
   RESPONSIVE — MOBILE (768px)
   ============================================ */

@media (max-width: 768px) {
    .flosc-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        transform: translateX(-100%);
        width: 280px;
        height: 100vh;
    }

    /* v1.8.1: Account for WP admin bar on mobile */
    .admin-bar .flosc-sidebar {
        top: 46px;
        height: calc(100vh - 46px);
    }

    .flosc-sidebar.open {
        transform: translateX(0);
    }

    /* Sidebar toggle already visible by default — no mobile override needed */

    .flosc-header {
        display: flex;
    }

    .flosc-main {
        padding-top: 0;
    }

    .flosc-messages,
    .messages {
        padding: 16px;
    }

    .flosc-input-composer,
    .flosc_input_composer {
        padding: 12px 16px 16px;
    }

    .flosc-message-content,
    .message-content {
        max-width: 85%;
    }

    .flosc-user-autoprompts,
    .flosc-user-autoprompts-container,
    #flosc_input_user_autoprompts_panel {
        padding: 12px 16px;
    }

    .flosc-greeting,
    .greeting {
        padding: 40px 16px 32px;
    }

    .flosc-greeting-title,
    .greeting-title {
        font-size: 22px;
    }

    .landing-title {
        font-size: 24px;
    }
}

/* ============================================
   OVERLAY (Mobile sidebar)
   ============================================ */

.flosc-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
}

.flosc-overlay.active {
    display: block;
}

/* ============================================
   MODAL SYSTEM
   ============================================ */

.flosc-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.flosc-modal-overlay.show {
    display: flex;
}

.flosc-modal {
    background: var(--flosc-bg, white);
    border-radius: 16px;
    max-width: 440px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.25);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.flosc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--flosc-border, #e5e7eb);
}

.flosc-modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--flosc-text, #111827);
    letter-spacing: -0.02em;
}

.flosc-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--flosc-text-muted, #6b7280);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.flosc-modal-close:hover {
    background: var(--flosc-sidebar-hover, #f3f4f6);
    color: var(--flosc-text, #111827);
}

.flosc-modal-body {
    padding: 22px;
}

/* ============================================
   QUIZ MODAL
   ============================================ */

.flosc-recording-modal {
    max-width: 400px;
}

.flosc-recording-instructions {
    text-align: center;
    color: var(--flosc-text-muted, #6b7280);
    margin-bottom: 24px;
    line-height: 1.6;
}

.waveform-container {
    background: var(--flosc-sidebar-hover, #f3f4f6);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

#waveformCanvas {
    width: 100%;
    height: 60px;
}

.flosc-recording-timer {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-bottom: 20px;
    color: var(--flosc-text, #111827);
}

.flosc-recording-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.flosc-record-btn, .flosc-stop-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 28px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flosc-record-btn {
    background: #ef4444;
    color: white;
}

.flosc-record-btn:hover {
    background: #dc2626;
}

.flosc-stop-btn {
    background: var(--flosc-text, #111827);
    color: white;
}

.flosc-recording-playback {
    margin-top: 20px;
}

.flosc-recording-playback audio {
    width: 100%;
    margin-bottom: 16px;
}

.playback-actions {
    display: flex;
    gap: 12px;
}

.playback-actions button {
    flex: 1;
}

.flosc-recording-error {
    text-align: center;
    color: #ef4444;
    padding: 20px;
}

/* Quiz Prompt */
.quiz-prompt {
    border-radius: 14px;
    padding: 22px;
    text-align: center;
    margin-bottom: 20px;
}

.quiz-prompt-label {
    font-size: 14px;
    margin: 0 0 10px 0;
}

.quiz-sequence {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    margin: 0;
}

/* Quiz Tabs */
.quiz-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.quiz-tab-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

/* Quiz Panels */
.quiz-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-text-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid;
    border-radius: 12px;
    font-size: 18px;
    text-align: center;
    letter-spacing: 2px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.quiz-text-input:focus {
    outline: none;
}

.quiz-submit-btn,
.flosc-quiz-submit-btn {
    width: 100%;
    margin-top: 4px;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Quiz Audio Panel */
.quiz-audio-panel {
    flex-direction: column;
    align-items: center;
}

.quiz-waveform {
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.quiz-timer {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 16px;
    font-variant-numeric: tabular-nums;
}

.quiz-recording-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.quiz-record-btn,
.quiz-stop-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-recording-status {
    font-size: 14px;
    text-align: center;
    min-height: 20px;
    margin-top: 12px;
}

.quiz-playback {
    margin-top: 16px;
    width: 100%;
}

.quiz-playback-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.quiz-playback-actions button {
    flex: 1;
}

.quiz-error {
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 16px;
}

.quiz-error p {
    margin: 0;
}

/* Quiz Result */
.quiz-result-panel {
    text-align: center;
    padding: 22px;
}

.quiz-score-display {
    font-size: 52px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.04em;
}

.quiz-result-message {
    margin-bottom: 22px;
    line-height: 1.6;
}

.quiz-continue-btn {
    padding: 14px 32px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* ============================================
   QUIZ RESULTS — Premium Card (v1.4.6)
   ============================================ */

.flosc-quiz-result {
    border-radius: 18px;
    padding: 32px;
    text-align: center;
    margin: 12px 0;
    position: relative;
    overflow: hidden;
}

.flosc-quiz-result-score {
    font-size: 68px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 8px;
    letter-spacing: -0.04em;
}

.flosc-quiz-result-label {
    font-size: 17px;
    margin-bottom: 22px;
    line-height: 1.5;
    font-weight: 500;
}

.flosc-quiz-result-cta {
    padding: 13px 30px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid;
    display: inline-block;
}

/* ============================================
   SANDBOX PAYMENT (v1.4.6)
   ============================================ */

.flosc-sandbox-payment {
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    margin: 16px 0;
    position: relative;
    overflow: hidden;
}

.flosc-sandbox-payment h3 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.flosc-sandbox-payment p {
    margin: 0 0 16px;
}

.flosc-sandbox-amount {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.flosc-sandbox-amount span {
    font-size: 26px;
    font-weight: 800;
}

.flosc-sandbox-amount input {
    font-size: 30px;
    font-weight: 800;
    width: 180px;
    text-align: right;
    border: 2px solid;
    border-radius: 12px;
    padding: 10px 14px;
    transition: all 0.2s ease;
}

.flosc-sandbox-amount input:focus {
    outline: none;
}

.flosc-sandbox-presets {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.flosc-sandbox-presets button {
    padding: 7px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.flosc-sandbox-pay-btn {
    border: none;
    padding: 15px 36px;
    border-radius: 999px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
}

.flosc-sandbox-success {
    padding: 32px;
    border-radius: 18px;
    text-align: center;
}

.flosc-sandbox-success h3 {
    font-size: 28px;
    margin: 0 0 8px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.flosc-sandbox-success .amount {
    font-size: 52px;
    font-weight: 800;
    margin: 16px 0;
    letter-spacing: -0.04em;
}

/* ============================================
   SHARE MODAL
   ============================================ */

.flosc-share-text {
    color: var(--flosc-text-muted, #6b7280);
    margin-bottom: 16px;
    line-height: 1.6;
}

.flosc-share-link-container {
    display: flex;
    gap: 8px;
}

.flosc-share-link-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--flosc-border, #e5e7eb);
    border-radius: 8px;
    font-size: 14px;
    background: var(--flosc-sidebar-hover, #f3f4f6);
    color: var(--flosc-text, #111827);
}

.flosc-copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--flosc-accent, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s ease;
}

.flosc-copy-btn:hover {
    background: var(--flosc-accent-hover, #1d4ed8);
}

/* ============================================
   PAYMENT MODAL
   ============================================ */

.flosc-payment-modal {
    max-width: 420px;
}

.flosc-payment-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--flosc-sidebar-hover, #f3f4f6);
    border-radius: 10px;
    margin-bottom: 20px;
}

.flosc-payment-product {
    display: flex;
    align-items: center;
    gap: 12px;
}

.flosc-product-icon {
    font-size: 32px;
}

.flosc-product-name {
    font-weight: 600;
    color: var(--flosc-text, #111827);
}

.flosc-product-desc {
    font-size: 13px;
    color: var(--flosc-text-muted, #6b7280);
}

.flosc-payment-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--flosc-text, #111827);
}

.flosc-payment-form {
    margin-bottom: 20px;
}

.flosc-payment-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--flosc-text, #111827);
}

.flosc-stripe-card-element {
    padding: 12px;
    border: 1px solid var(--flosc-border, #e5e7eb);
    border-radius: 8px;
    background: white;
}

.flosc-stripe-errors {
    color: #ef4444;
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

.flosc-pay-btn {
    width: 100%;
    padding: 14px;
    background: var(--flosc-accent, #2563eb);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.flosc-pay-btn:hover:not(:disabled) {
    background: var(--flosc-accent-hover, #1d4ed8);
}

.flosc-pay-btn:disabled {
    background: var(--flosc-text-muted, #6b7280);
    cursor: not-allowed;
}

.flosc-pay-btn.loading .flosc-pay-btn-text {
    visibility: hidden;
}

.flosc-pay-btn-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

.flosc-pay-btn.loading .flosc-pay-btn-spinner {
    display: block;
}

@keyframes spinner {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.flosc-payment-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    color: var(--flosc-text-muted, #6b7280);
    font-size: 13px;
}

/* v1.6.9: PayPal + Stripe payment separator */
.flosc-payment-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 16px 0;
    color: var(--flosc-text-muted, #9ca3af);
    font-size: 13px;
}

.flosc-payment-separator::before,
.flosc-payment-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--flosc-border, #e5e7eb);
}

.flosc-payment-separator span {
    padding: 0 12px;
}

.flosc-paypal-buttons {
    min-height: 45px;
}

/* ============================================
   LOGIN GATE
   ============================================ */

/* v1.7.0: Quiz results gate (inline in chat for visitors) */
.flosc-quiz-gate {
    text-align: center;
    padding: 24px 20px;
    border-radius: 14px;
    background: var(--flosc-bg-secondary, #f9fafb);
    border: 1px solid var(--flosc-border, #e5e7eb);
    max-width: 400px;
    margin: 0 auto;
}

.flosc-gate-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.flosc-gate-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--flosc-text-primary, #111827);
}

.flosc-gate-text {
    font-size: 14px;
    color: var(--flosc-text-muted, #6b7280);
    margin-bottom: 16px;
    line-height: 1.5;
}

.flosc-gate-btn {
    display: inline-block;
    padding: 14px 32px;
    background: #2563eb !important;
    color: #ffffff !important;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    text-decoration: none;
    letter-spacing: -0.01em;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.flosc-gate-btn:hover {
    background: #1d4ed8 !important;
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
    text-decoration: none;
}

.flosc-gate-btn:active {
    transform: translateY(0);
}

/* Login gate modal */
.flosc-login-gate-body {
    text-align: center;
}

.flosc-login-gate-body p {
    color: var(--flosc-text-muted, #6b7280);
    margin-bottom: 24px;
    line-height: 1.6;
}

.flosc-login-gate-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flosc-login-gate-buttons .btn-primary,
.flosc-login-gate-buttons .btn-large {
    padding: 14px 24px;
    background: var(--flosc-accent, #2563eb);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flosc-login-gate-buttons .btn-primary:hover {
    background: var(--flosc-accent-hover, #1d4ed8);
}

.flosc-login-gate-buttons .btn-secondary {
    padding: 14px 24px;
    background: transparent;
    color: var(--flosc-accent, #2563eb);
    border: 1px solid var(--flosc-accent, #2563eb);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.flosc-login-gate-buttons .btn-secondary:hover {
    background: rgba(37, 99, 235, 0.1);
}

/* ============================================
   CONTENT PROTECTION LAYOUT
   ============================================ */

.flosc-protected-content {
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.flosc-protected-content.flosc-teaser .flosc-teaser-excerpt {
    line-height: 1.7;
    margin-bottom: 1rem;
}

.flosc-protected-content.flosc-preview .flosc-preview-content {
    line-height: 1.7;
}

.flosc-protected-notice {
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    text-align: center;
}

.flosc-protected-notice p {
    margin: 0;
}

.flosc-chatbot-cta {
    text-align: center;
    margin-top: 1rem;
}

.flosc-cta-button {
    display: inline-block;
    padding: 0.85rem 1.75rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}

/* ============================================
   SIDEBAR OVERLAY (Mobile)
   ============================================ */

/* v2.0.5: z-index must be LOWER than mobile sidebar (50) so overlay
   darkens the main content but doesn't block sidebar interaction. */
.flosc-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 49;
}

.flosc-sidebar-overlay.show {
    display: block;
}

/* ============================================
   USER STATE VISIBILITY
   Profile bar is always visible (content toggled via data-show above).
   These rules control OTHER sidebar elements by state.
   ============================================ */

[data-user-state="visitor"] .session-history,
[data-user-state="visitor"] .flosc-share-btn,
[data-user-state="visitor"] .flosc_app_session_list,
[data-user-state="visitor"] .new-chat-btn {
    display: none !important;
}

[data-user-state="visitor"] .auth-buttons {
    display: flex !important;
}

[data-user-state="guest"] .auth-buttons,
[data-user-state="member"] .auth-buttons {
    display: none !important;
}

[data-user-state="guest"] .flosc-share-btn,
[data-user-state="member"] .flosc-share-btn {
    display: flex !important;
}

[data-user-state="guest"] .flosc_app_session_list,
[data-user-state="member"] .flosc_app_session_list {
    display: block !important;
}

[data-user-state="member"] .upgrade-banner {
    display: none !important;
}

[data-user-state="guest"] .upgrade-banner {
    display: flex !important;
}

/* ============================================
   LOADING STATES
   ============================================ */

.flosc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.flosc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible for keyboard navigation */
.flosc-app *:focus-visible {
    outline: 2px solid var(--flosc-accent, #2563eb);
    outline-offset: 2px;
}

/* ============================================
   PROMPT PANEL / INTRO PANEL
   ============================================ */

.prompt-panel,
.intro-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    align-self: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 16px;
}

.prompt-panel-inline,
.intro-panel-inline {
    max-width: 1100px;
    width: 100%;
    margin: 12px auto 0;
    align-items: stretch;
    padding: 12px 16px;
    border-radius: 16px;
}

/* v2.0.1: Tighter header spacing */
.prompt-panel-header,
.intro-panel-header {
    display: grid;
    grid-template-columns: 1fr auto 40px;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.prompt-panel-eyebrow,
.intro-panel-eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.prompt-panel-title,
.intro-panel-title {
    justify-self: center;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* v2.0.1: Minimal body padding for compact panel */
.prompt-panel-body,
.intro-panel-body {
    padding: 4px;
}

.prompt-panel-inline .flosc_input_user_autoprompts_panel_scroll,
.intro-panel-inline .flosc_input_user_autoprompts_panel_scroll {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
}

.prompt-panel-close,
.intro-panel-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 10;
    font-size: 14px;
    line-height: 1;
    border: none;
}

/* ============================================
   BUTTON ICON FIX (legacy v9.2.3 compat)
   ============================================ */

/* Sidebar action buttons */
.sidebar-action-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #667;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-action-btn:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

.sidebar-action-btn:active {
    transform: scale(0.95);
}

/* Send button */
.flosc_input_chat_send_button {
    background: #4f46e5;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: white;
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.flosc_input_chat_send_button:hover {
    background: #4338ca;
}

/* Sidebar toggle */
.flosc_app_sidebar_toggle {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--flosc-text-secondary, #6b7280);
    border-radius: 8px;
}

.flosc_app_sidebar_toggle:hover {
    background: var(--flosc-hover, #f5f5f5);
    color: var(--flosc-text-primary, #374151);
}

/* ============================================
   LESSON LIST & CONTENT
   ============================================ */

.flosc-lesson-list {
    max-width: 680px;
    margin: 16px 0;
}

.flosc-lesson-list-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--flosc-border, #e5e7eb);
}

.flosc-lesson-list-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.flosc-lesson-list-header p {
    font-size: 14px;
    color: var(--flosc-text-muted, #6b7280);
    margin: 0;
}

.flosc-lesson-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flosc-lesson-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--flosc-surface, #ffffff);
    border: 1px solid var(--flosc-border, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flosc-lesson-item:hover {
    border-color: var(--flosc-primary, #4f46e5);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.flosc-lesson-item-content {
    flex: 1;
    min-width: 0;
}

.flosc-lesson-item-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--flosc-text, #1f2937);
    display: block;
    margin-bottom: 4px;
}

.flosc-lesson-item-excerpt {
    font-size: 13px;
    color: var(--flosc-text-muted, #6b7280);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.flosc-lesson-item-arrow {
    font-size: 18px;
    color: var(--flosc-text-muted, #9ca3af);
    margin-left: 12px;
    flex-shrink: 0;
}

.flosc-lesson-item:hover .flosc-lesson-item-arrow {
    color: var(--flosc-primary, #4f46e5);
}

/* WordPress Lesson Content */
.flosc-wp-lesson {
    max-width: 680px;
    margin: 16px 0;
}

.flosc-wp-lesson-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--flosc-border, #e5e7eb);
}

.flosc-wp-lesson-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: var(--flosc-text, #1f2937);
}

/* WordPress content renders with its own theme styling — no overrides */
.flosc-wp-lesson-content img {
    max-width: 100%;
    height: auto;
}

.flosc-wp-lesson-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--flosc-border, #e5e7eb);
}

.flosc-back-to-lessons-btn {
    padding: 10px 20px;
    background: var(--flosc-bg-hover, #f3f4f6);
    color: var(--flosc-text, #374151);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.flosc-back-to-lessons-btn:hover {
    background: var(--flosc-border, #e5e7eb);
    color: var(--flosc-text, #1f2937);
}

@media (max-width: 768px) {
    .flosc-lesson-list,
    .flosc-wp-lesson {
        max-width: 100%;
    }

    .flosc-lesson-item {
        padding: 10px 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   v1.9.0: AI Correction Flag Button + Modal (admin-only)
   ═══════════════════════════════════════════════════════════════ */

/* Flag button — appears on hover of assistant messages */
.flosc-correction-flag {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--flosc-text-muted, #94a3b8);
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}

.message.assistant .message-content {
    position: relative;
}

/* Admin feedback wrapper — holds praise + flag buttons */
.flosc-admin-feedback {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message.assistant:hover .flosc-admin-feedback {
    opacity: 0.6;
}

.message.assistant:hover .flosc-admin-feedback:hover {
    opacity: 1;
}

/* Legacy standalone flag — still hide on hover */
.message.assistant:hover .flosc-correction-flag {
    opacity: 0.6;
}

.flosc-correction-flag:hover {
    opacity: 1 !important;
    color: var(--flosc-warning, #f59e0b);
    background: var(--flosc-surface-hover, rgba(0, 0, 0, 0.05));
}

/* Praise button */
.flosc-praise-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--flosc-text-muted, #94a3b8);
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: opacity 0.2s, color 0.2s;
}

.flosc-praise-btn:hover {
    color: var(--flosc-success, #22c55e);
    background: var(--flosc-surface-hover, rgba(0, 0, 0, 0.05));
}

/* Praise modal header — green accent */
.flosc-praise-header {
    border-bottom-color: #bbf7d0;
}

/* Praise good response preview — green */
.flosc-correction-preview.flosc-praise-good {
    border-color: #86efac;
    background: #f0fdf4;
}

/* Praise submit button — green */
.flosc-praise-submit-btn {
    background: #22c55e !important;
}

.flosc-praise-submit-btn:hover {
    background: #16a34a !important;
}

/* Modal overlay */
.flosc-correction-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;
}

/* Modal container */
.flosc-correction-modal {
    background: var(--flosc-surface, #fff);
    border-radius: 12px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.flosc-correction-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--flosc-border, #e2e8f0);
}

.flosc-correction-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--flosc-text, #1e293b);
}

.flosc-correction-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--flosc-text-muted, #94a3b8);
    padding: 0 4px;
    line-height: 1;
}

.flosc-correction-modal-close:hover {
    color: var(--flosc-text, #1e293b);
}

.flosc-correction-modal-body {
    padding: 20px;
}

.flosc-correction-field {
    margin-bottom: 16px;
}

.flosc-correction-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--flosc-text, #1e293b);
    margin-bottom: 6px;
}

.flosc-correction-field .required {
    color: #ef4444;
}

.flosc-correction-field .optional {
    color: var(--flosc-text-muted, #94a3b8);
    font-weight: 400;
}

.flosc-correction-preview {
    background: var(--flosc-surface-alt, #f8fafc);
    border: 1px solid var(--flosc-border, #e2e8f0);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--flosc-text, #1e293b);
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
}

.flosc-correction-preview.flosc-correction-bad {
    border-color: #fca5a5;
    background: #fef2f2;
}

.flosc-correction-field textarea {
    width: 100%;
    border: 1px solid var(--flosc-border, #e2e8f0);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    color: var(--flosc-text, #1e293b);
    background: var(--flosc-surface, #fff);
    box-sizing: border-box;
}

.flosc-correction-field textarea:focus {
    outline: none;
    border-color: var(--flosc-primary, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.flosc-correction-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--flosc-border, #e2e8f0);
}

.flosc-correction-cancel {
    padding: 8px 16px;
    border: 1px solid var(--flosc-border, #e2e8f0);
    background: var(--flosc-surface, #fff);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--flosc-text, #1e293b);
}

.flosc-correction-cancel:hover {
    background: var(--flosc-surface-alt, #f8fafc);
}

.flosc-correction-submit {
    padding: 8px 20px;
    border: none;
    background: var(--flosc-primary, #4f46e5);
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.flosc-correction-submit:hover {
    opacity: 0.9;
}

.flosc-correction-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
