/**
 * ZAV Chat Widget - Stealth Emerald Tech Edition
 */

/* Container */
#zav-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: var(--font-body, 'Inter', sans-serif);
    pointer-events: none;
    /* Let clicks pass through container, toggle/window handle their own */
}

/* Chat typography mapping */
.chat-header-info h3,
.quick-action,
.chat-close,
.chat-toggle::after {
    font-family: var(--font-primary, 'Space Grotesk', sans-serif);
}

.chat-header-status,
.chat-message .message-content,
.chat-input,
.chat-input-mirror,
.message-time {
    font-family: var(--font-body, 'Inter', sans-serif);
}

/* Toggle Button - Restored (Independent of ZAV) */
.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #050505;
    border: 1px solid #34D399;
    box-shadow: 0 0 15px rgba(52, 211, 153, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    /* Always visible */
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10001;
    pointer-events: auto;
    color: #34D399;
    overflow: visible;
}

/* CTA label injected via wp_head (.chat-toggle::after { content: ... }) */
.chat-toggle::after {
    position: absolute;
    right: 72px;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(5, 5, 5, 0.92);
    border: 1px solid rgba(52, 211, 153, 0.55);
    color: #34D399;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    transition:
        opacity 0.25s ease,
        transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.25s ease;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.65);
}

.chat-toggle.show-cta::after,
.chat-toggle:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    filter: drop-shadow(0 0 10px rgba(52, 211, 153, 0.22));
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(52, 211, 153, 0.6);
    color: #00FFA3;
}

.chat-toggle-icon {
    width: 26px;
    height: 26px;
    color: currentColor;
    display: block;
    position: relative;
    z-index: 10002;
    flex: 0 0 auto;
}

.chat-toggle-icon .icon-ring {
    fill: none;
    stroke: #34D399;
    stroke-width: 1.8;
    opacity: 0.85;
    transform-origin: 50% 50%;
    animation: chat-icon-ring 2.4s ease-in-out infinite;
}

.chat-toggle-icon .icon-core {
    fill: #34D399;
    filter: drop-shadow(0 0 4px rgba(52, 211, 153, 0.65));
    transform-origin: 50% 50%;
    animation: chat-icon-core 1.4s ease-in-out infinite;
}

.chat-toggle-icon .icon-scan {
    fill: none;
    stroke: #34D399;
    stroke-width: 1.8;
    stroke-linecap: round;
    opacity: 0.9;
    stroke-dasharray: 3 4;
    animation: chat-icon-scan 1.5s linear infinite;
}

.chat-toggle:hover .chat-toggle-icon {
    color: #00FFA3;
}

.chat-toggle:hover .chat-toggle-icon .icon-ring,
.chat-toggle:hover .chat-toggle-icon .icon-scan {
    stroke: #00FFA3;
    opacity: 1;
}

.chat-toggle:hover .chat-toggle-icon .icon-core {
    fill: #00FFA3;
    filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.75));
}

@keyframes chat-icon-ring {
    0%,
    100% {
        transform: scale(0.92);
        opacity: 0.75;
    }

    50% {
        transform: scale(1.06);
        opacity: 1;
    }
}

@keyframes chat-icon-core {
    0%,
    100% {
        transform: scale(0.9);
    }

    50% {
        transform: scale(1.08);
    }
}

@keyframes chat-icon-scan {
    0% {
        stroke-dashoffset: 0;
    }

    100% {
        stroke-dashoffset: -14;
    }
}

/* Chat Window - Tech Frame */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: rgba(5, 5, 5, 0.95);
    /* Deep Void */
    border: 1px solid #262626;
    border-radius: 12px;
    /* Sharper corners */
    overflow: hidden;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);

    /* Global scrollbar style for chat window */
    scrollbar-width: thin;
    scrollbar-color: #34D399 #050505;
}

.chat-window * {
    box-sizing: border-box !important;
}

/* Tech Decor Lines */
.chat-window::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    width: 40px;
    height: 2px;
    background: #34D399;
    box-shadow: 0 0 10px #34D399;
    z-index: 2;
}

.zav-chat.open .chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Measurement mode: makes avatar measurable before open without visual flash */
.zav-chat.measure-target .chat-avatar {
    transform: scale(1) !important;
    transition: none !important;
}

/* Temporary flying orb used for dock/undock animation */
.zav-flight-orb {
    position: fixed;
    left: 0;
    top: 0;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 110000;
    background: radial-gradient(circle at center, #FFFFFF 10%, #E0FFF8 30%, #00FFA3 80%, rgba(0, 255, 163, 0.1) 100%);
    border: 1px solid rgba(0, 255, 163, 0.5);
    box-shadow:
        0 0 28px rgba(52, 211, 153, 0.8),
        0 0 60px rgba(52, 211, 153, 0.45),
        inset 0 0 18px rgba(255, 255, 255, 0.55);
    transform-origin: center center;
    will-change: transform, opacity;
}

.zav-flight-orb .zav-flight-eyes {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 8px;
}

.zav-flight-orb .zav-flight-eye {
    width: 5px;
    height: 9px;
    border-radius: 4px;
    background: #002b1b;
}

/* Inbound Flight Eyes (Matches Site Orb) */
.zav-flight-orb.zav-flight-in .zav-flight-eyes {
    top: 35%;
    gap: 20px;
}

.zav-flight-orb.zav-flight-in .zav-flight-eye {
    width: 12px;
    height: 20px;
    border-radius: 6px;
}

/* Header */
.chat-header {
    padding: 20px;
    background: rgba(18, 18, 18, 0.8);
    border-bottom: 1px solid #262626;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    position: relative;
    /* Initial state hidden, scales in */
    transform: scale(0);
    transition: transform 0.4s cubic-bezier(0.3, 1.5, 0.6, 1);
}

.chat-avatar-orb {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle at center, #FFFFFF 12%, #E0FFF8 34%, #34D399 82%, rgba(52, 211, 153, 0.12) 100%);
    border: 1px solid rgba(52, 211, 153, 0.45);
    box-shadow:
        0 0 14px rgba(52, 211, 153, 0.75),
        0 0 26px rgba(52, 211, 153, 0.35),
        inset 0 0 10px rgba(255, 255, 255, 0.55);
    position: relative;
    overflow: hidden;
}

.chat-avatar-eyes {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 8px;
    z-index: 2;
    will-change: transform;
}

.chat-eye {
    width: 5px;
    height: 9px;
    background: #002b1b;
    border-radius: 4px;
    transition: all 0.25s ease;
}

.zav-chat.open .chat-avatar-orb {
    animation: chat-avatar-float 3.8s ease-in-out infinite;
}

.chat-avatar.state-thinking .chat-eye {
    height: 4px;
    border-radius: 6px;
}

.chat-avatar.state-ack .chat-eye {
    transform: scaleY(0.2);
}

.chat-avatar.state-joy .chat-eye {
    height: 5px;
    border-radius: 9px 9px 2px 2px;
}

.chat-avatar.state-alert .chat-eye {
    width: 6px;
    height: 11px;
}

.chat-avatar.state-blink .chat-eye {
    animation: chat-avatar-blink 0.5s ease-in-out;
}

@keyframes chat-avatar-blink {
    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.1);
    }
}

@keyframes chat-avatar-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

/* When chat is open, avatar pops in */
.zav-chat.open .chat-avatar {
    transform: scale(1);
    transition-delay: 0.3s;
    /* Wait for Fly-In */
}

.chat-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #EDEDED;
    letter-spacing: 0.5px;
}

/* Quick Actions */
.chat-quick-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.quick-action {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--zav-mist);
    padding: 6px 12px;
    border-radius: 4px;
    /* Tech sharp */
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}

.quick-action:hover {
    border-color: #34D399;
    background: rgba(52, 211, 153, 0.05);
    color: #34D399;
}

/* Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Strictly no horizontal scroll */
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg, rgba(5, 5, 5, 0) 0%, rgba(5, 5, 5, 0.8) 100%);
    scrollbar-width: thin;
    scrollbar-color: #34D399 #050505;
}

/* Custom Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #050505;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #27272a;
    /* Desaturated scrollbar */
    border-radius: 10px;
    border: 2px solid #050505;
}

/* Force removal of horizontal scroll on any browser */
.chat-messages,
.chat-window,
.chat-input-container {
    overflow-x: hidden !important;
}

.chat-message {
    display: flex;
    width: 100% !important;
    max-width: 100% !important;
}

.chat-message {
    display: flex;
}

.chat-message.bot {
    justify-content: flex-start;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message .message-content {
    display: inline-block;
    max-width: 85% !important;
    overflow-wrap: anywhere !important;
    /* Hard break long strings */
    word-break: break-word !important;
    /* Traditional wrap */
    position: relative;
}

.chat-message.user .message-content {
    max-width: 62%;
}

.message-time {
    font-size: 10px;
    line-height: 1;
    margin-top: 6px;
    opacity: 0.55;
}

.chat-message.user .message-time {
    text-align: right;
}

.chat-message.bot .message-content {
    background: #121212;
    color: #EDEDED;
    border-left: 3px solid #34D399;
    /* Dialogue Indicator */
    border-radius: 4px 12px 12px 12px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.35;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.chat-message.user .message-content {
    background: #27272a;
    /* Deep Zinc Grey */
    color: #EDEDED;
    border-radius: 12px 12px 4px 12px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Bot Link Styling */
.chat-message.bot .message-content a {
    color: #34D399 !important;
    text-decoration: underline !important;
    text-underline-offset: 2px;
    font-weight: 600;
    transition: color 0.2s ease;
}

.chat-message.bot .message-content a:hover {
    color: #00FFA3 !important;
    filter: drop-shadow(0 0 5px rgba(52, 211, 153, 0.4));
}

/* Bot live typing cursor */
.chat-message.bot .message-text {
    white-space: pre-wrap;
}

.chat-message.bot .message-cursor {
    display: inline-block;
    margin-left: 4px;
    color: #34D399;
    animation: chat-caret-blink 0.8s steps(1) infinite !important;
}

/* No margin when it's the only thing in the bubble */
.typing-indicator-msg .message-cursor {
    margin-left: 0;
}

/* Input */
.chat-input-container {
    padding: 15px;
    background: #121212;
    border-top: 1px solid #262626;
}

.chat-input-wrapper {
    background: #050505;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 18px 18px;
    min-height: 56px;
    display: flex;
    align-items: center;
    position: relative;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #FFF;
    outline: none;
    caret-color: transparent !important;
    position: relative;
    z-index: 2;
    padding: 4px 0;
    margin: 0;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    letter-spacing: 0 !important;
}

/* Custom block cursor overlay (visual only) */
.chat-input-overlay {
    position: absolute;
    left: 18px;
    right: 46px;
    top: 18px;
    bottom: 18px;
    display: flex;
    align-items: center;
    pointer-events: none;
    z-index: 1;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    font: inherit;
    letter-spacing: inherit;
}

.chat-input-overlay::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.chat-input-overlay.hidden {
    opacity: 0;
}

.chat-input-mirror {
    white-space: pre;
    color: transparent;
    font-family: 'Inter', sans-serif !important;
    font-size: 15px;
    letter-spacing: 0;
}

.chat-input-caret {
    color: #34D399;
    margin-left: -1px;
    display: inline-block;
    line-height: 1;
    font-size: 14px;
    vertical-align: middle;
    animation: chat-caret-blink 0.8s steps(1) infinite;
    transform: translateY(-1px) translateX(var(--chat-caret-nudge, 0px));
    transform-origin: left center;
    will-change: transform, opacity;
    visibility: hidden;
    transition: none;
    font-weight: 400;
    height: 1em;
}

.chat-input-caret.visible {
    visibility: visible;
}

.chat-input-wrapper.typing .chat-input-caret,
.chat-input-caret.active-typing {
    text-shadow: 0 0 10px rgba(52, 211, 153, 0.82);
    transform: translateX(var(--chat-caret-nudge, 0px)) scale(1.1);
    transition: transform 0.1s ease-out;
}

@keyframes chat-caret-blink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

.chat-send {
    background: none;
    border: none;
    color: #34D399;
    cursor: pointer;
}

.chat-send svg {
    width: 20px;
    height: 20px;
    display: block;
}

.chat-send svg line {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    fill: none;
}

.chat-send svg polygon {
    fill: currentColor;
}

/* Mobile */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: min(620px, calc(100vh - 140px));
        right: 0px;
        bottom: 80px;
        border-radius: 16px;
    }

    .chat-toggle {
        width: 50px;
        height: 50px;
    }

    .chat-toggle::after {
        display: none !important;
        /* Hide CTA label on mobile to save space */
    }
}

/* Close Button */
.chat-close {
    background: transparent;
    border: none;
    color: #34D399;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
    opacity: 0.7;
    transition: all 0.2s;
    height: 30px;
    border-radius: 4px;
    margin-left: 8px;
    /* Separate from other buttons */
}

.chat-close:hover {
    color: #FFF;
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Ensure mobile toggle is/* Mobile Logic - Restore Orb visibility with safe positioning */
@media (max-width: 768px) {
    .zav-character {
        --current-scale: 0.8 !important;
        /* Slightly smaller on mobile */
        top: auto !important;
        bottom: 100px !important;
        /* Above chat toggle */
        left: 20px !important;
        right: auto !important;
        pointer-events: none;
        /* Reduce accidental taps */
    }

    .zav-orb {
        animation-duration: 6s !important;
        /* Slower float to save battery */
    }

    .zav-character.zav-joy-roll .zav-orb {
        animation-duration: 0.45s !important;
        /* Keep roll speed consistent */
    }
}

/* Ensure mobile toggle is visible */
@media (max-width: 768px) {
    .chat-toggle {
        display: flex !important;
        /* Restore on mobile */
    }
}
/* ==========================================================================
   MOBILE OPTIMIZATION - Chat Widget
   ========================================================================== */

@media (max-width: 768px) {
  /* Chat Container - Bottom Right with Safe Area Support */
  #zav-chat {
    position: fixed;
    bottom: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
    left: auto;
    z-index: 9999;
  }

  /* Chat Toggle Button - Smaller on mobile */
  .chat-toggle {
    width: 50px !important;
    height: 50px !important;
  }

  /* Chat Window - Full screen overlay on mobile with flex column layout */
  .chat-window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none;
    z-index: 99999;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  /* Sticky header on mobile - ALWAYS sticky, not just with keyboard */
  .chat-window .chat-header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
    flex-shrink: 0 !important;
    background: var(--zav-carbon, #121212) !important;
    width: 100% !important;
  }

  /* Messages container should scroll, not the whole window */
  .chat-window .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative !important;
  }

  /* Input container at bottom */
  .chat-window .chat-input-container {
    flex-shrink: 0 !important;
    position: relative !important;
    background: var(--zav-carbon, #121212) !important;
    border-top: 1px solid rgba(52, 211, 153, 0.2) !important;
    width: 100% !important;
  }

  /* Hide toggle when chat is active */
  .zav-chat.open .chat-toggle {
    display: none !important;
  }

  /* Close button - larger and more visible on mobile */
  .zav-chat.open .chat-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    opacity: 1;
    padding: 0;
  }

  /* Messages fill available space */
  .chat-messages {
    flex: 1 !important;
    max-height: none !important;
  }
}

/* Final mobile edge safety override */
@media (max-width: 768px) {
  #zav-chat {
    right: max(18px, env(safe-area-inset-right)) !important;
    bottom: max(18px, calc(18px + env(safe-area-inset-bottom))) !important;
    left: auto !important;
  }

  .chat-toggle {
    width: 44px !important;
    height: 44px !important;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .chat-window {
    width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
  }
}

/* Mobile keyboard compensation - Simplified */
@media (max-width: 768px) {
  /* When keyboard is open, keep the same layout but adjust for viewport */
  .chat-window.keyboard-open {
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  /* Ensure messages scroll properly when keyboard is visible */
  .chat-window.keyboard-open .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }
}

/* ==========================================================================
   PREMIUM MINIMAL CHAT WIDGET OVERRIDES
   ========================================================================== */

#zav-chat {
    right: 20px;
    bottom: 20px;
}

.chat-toggle {
    width: 56px;
    height: 56px;
    border: 1px solid rgba(52, 211, 153, 0.45);
    background: rgba(12, 12, 12, 0.96);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(52, 211, 153, 0.08) inset;
}

.chat-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(52, 211, 153, 0.2) inset;
}

.chat-toggle::after {
    right: 68px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(18, 18, 18, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #d6d6d8;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1px;
}

.chat-window {
    width: 400px;
    height: 640px;
    max-height: calc(100vh - 120px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(180deg, rgba(18, 18, 18, 0.98) 0%, rgba(10, 10, 10, 0.98) 100%);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(8px);
}

.chat-window::before {
    display: none;
}

.chat-header {
    padding: 14px 16px;
    gap: 10px;
    background: rgba(16, 16, 16, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-avatar,
.chat-avatar-orb {
    width: 38px;
    height: 38px;
}

.chat-header-info h3 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: #f1f1f2;
}

.chat-header-status {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #a1a1aa;
    letter-spacing: 0;
}

.chat-close {
    margin-left: 0;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #c4c4c8;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.chat-messages {
    padding: 14px;
    gap: 12px;
    background: transparent;
}

.chat-message .message-content {
    max-width: 78% !important;
    font-size: 13px;
    line-height: 1.45;
}

.chat-message.bot .message-content {
    background: #17181c;
    border-left: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
}

.chat-message.user .message-content {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #f4f4f5;
    border-radius: 12px;
    padding: 10px 12px;
}

.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 10px;
    margin: 0;
}

.quick-action {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.03);
    color: #d4d4d8;
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    padding: 7px 12px;
}

.quick-action:hover {
    border-color: rgba(52, 211, 153, 0.52);
    background: rgba(52, 211, 153, 0.11);
    color: #ecfdf5;
}

.chat-trust-line {
    font-size: 11px;
    color: #a1a1aa;
    padding: 0 14px 10px;
    line-height: 1.35;
}

.chat-input-container {
    padding: 12px 14px 14px;
    background: rgba(16, 16, 16, 0.94);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input-wrapper {
    min-height: 52px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: #0e0e10;
}

.chat-input {
    font-size: 14px;
}

.chat-send {
    color: #34D399;
}

@media (max-width: 768px) {
    #zav-chat {
        right: max(20px, env(safe-area-inset-right)) !important;
        bottom: max(20px, calc(20px + env(safe-area-inset-bottom))) !important;
    }

    .chat-window {
        width: 100vw !important;
        height: 100dvh !important;
        border-radius: 0 !important;
    }

    .chat-header {
        padding: 14px 12px;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-quick-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 12px 10px;
        scrollbar-width: none;
    }

    .chat-quick-actions::-webkit-scrollbar {
        display: none;
    }

    .quick-action {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .chat-trust-line {
        padding: 0 12px 10px;
        text-align: left;
    }

    .chat-input-container {
        padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    }
}

/* ==========================================================================
   TWO-STEP FLOW: HOME VIEW + CONVERSATION VIEW
   ========================================================================== */

.chat-home-view,
.chat-conversation-view {
    height: calc(100% - 67px);
}

.chat-home-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    overflow-y: auto;
}

.chat-conversation-view {
    display: none;
    flex-direction: column;
}

#zav-chat.chat-view-home .chat-home-view {
    display: flex;
}

#zav-chat.chat-view-home .chat-conversation-view {
    display: none;
}

#zav-chat.chat-view-conversation .chat-home-view {
    display: none;
}

#zav-chat.chat-view-conversation .chat-conversation-view {
    display: flex;
}

.chat-home-hero h4 {
    margin: 0 0 6px;
    font-size: 34px;
    line-height: 1.05;
    color: #f5f5f5;
    font-family: var(--font-primary, 'Space Grotesk', sans-serif);
    letter-spacing: -0.5px;
}

.chat-home-hero p {
    margin: 0;
    font-size: 14px;
    color: #b6b6be;
    line-height: 1.45;
}

.chat-response-pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 12px;
    color: #c7c7cf;
}

.chat-response-pill strong {
    color: #f3f3f4;
    font-weight: 600;
}

.chat-home-search input {
    width: 100%;
    height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: #efefef;
    color: #52525b;
    padding: 0 14px;
    font-size: 15px;
}

.chat-home-search-cta {
    width: 100%;
    height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: #d4d4d8;
    font-size: 14px;
    text-align: left;
    padding: 0 14px;
    cursor: pointer;
}

.chat-home-search-cta:hover {
    border-color: rgba(52, 211, 153, 0.45);
    color: #f4f4f5;
}

.chat-home-card {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 12px;
}

.chat-home-card h5 {
    margin: 2px 0 8px;
    font-size: 20px;
    color: #f4f4f5;
    font-family: var(--font-primary, 'Space Grotesk', sans-serif);
    letter-spacing: -0.4px;
}

.chat-home-action {
    width: 100%;
    text-align: left;
    display: block;
    border: none;
    background: transparent;
    color: #e4e4e7;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 18px 12px 0;
    position: relative;
    cursor: pointer;
}

.chat-home-action:first-of-type {
    border-top: none;
}

.chat-home-action::after {
    content: '›';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    color: #a1a1aa;
    font-size: 20px;
    line-height: 1;
}

.chat-home-action-title {
    display: block;
    font-size: 15px;
    color: #f4f4f5;
    font-weight: 500;
}

.chat-home-action-sub {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: #a1a1aa;
}

.chat-home-action,
.quick-action,
.chat-send,
.chat-close,
.chat-back,
.chat-theme-toggle,
.chat-toggle,
.chat-home-search-cta,
.chat-input {
    min-height: 44px;
}

.chat-send {
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-input {
    caret-color: #34D399 !important;
}

/* Use native input caret only (remove large custom block cursor) */
.chat-input-overlay,
.chat-input-caret {
    display: none !important;
}

.message-time {
    font-size: 12px;
    opacity: 0.72;
}

.chat-trust-line {
    font-size: 12px;
    color: #c4c4c8;
}

.chat-toggle:focus-visible,
.chat-close:focus-visible,
.chat-back:focus-visible,
.chat-theme-toggle:focus-visible,
.quick-action:focus-visible,
.chat-home-action:focus-visible,
.chat-home-search-cta:focus-visible,
.chat-send:focus-visible {
    outline: 2px solid #34D399;
    outline-offset: 2px;
}

.chat-input:focus,
.chat-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border-color: inherit !important;
}

@media (prefers-reduced-motion: reduce) {
    .chat-input-overlay {
        display: none !important;
    }
}

.chat-home-action:hover .chat-home-action-title,
.chat-home-action:hover::after {
    color: #34D399;
}

.chat-back {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #d4d4d8;
    background: transparent;
    margin-left: 0;
    margin-right: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
}

.chat-back:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.chat-theme-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #d4d4d8;
    background: transparent;
    margin-right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.chat-theme-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.chat-theme-toggle-icon {
    font-size: 14px;
    line-height: 1;
}

#zav-chat.chat-view-conversation .chat-back {
    display: inline-flex;
}

@media (max-width: 768px) {
    .chat-home-view,
    .chat-conversation-view {
        height: calc(100dvh - 67px);
    }

    .chat-home-hero h4 {
        font-size: 30px;
    }

    .chat-home-card h5 {
        font-size: 18px;
    }
}

/* ==========================================================================
   LIGHT THEME - CHAT WIDGET
   ========================================================================== */

#zav-chat.chat-theme-light .chat-toggle {
    background: #ffffff;
    border-color: #d0d5dd;
    color: #1f2937;
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.18);
}

#zav-chat.chat-theme-light .chat-toggle::after {
    background: #ffffff;
    border-color: #d0d5dd;
    color: #334155;
}

#zav-chat.chat-theme-light .chat-window {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #d0d5dd;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2);
}

#zav-chat.chat-theme-light .chat-header {
    background: rgba(255, 255, 255, 0.92);
    border-bottom-color: #e4e7ec;
}

#zav-chat.chat-theme-light .chat-header-info h3 {
    color: #111827;
}

#zav-chat.chat-theme-light .chat-header-status {
    color: #475467;
}

#zav-chat.chat-theme-light .chat-close,
#zav-chat.chat-theme-light .chat-back,
#zav-chat.chat-theme-light .chat-theme-toggle {
    border-color: #d0d5dd;
    color: #475467;
    background: #ffffff;
}

#zav-chat.chat-theme-light .chat-close:hover,
#zav-chat.chat-theme-light .chat-back:hover,
#zav-chat.chat-theme-light .chat-theme-toggle:hover {
    color: #111827;
    background: #f8fafc;
}

#zav-chat.chat-theme-light .chat-home-hero h4 {
    color: #111827;
}

#zav-chat.chat-theme-light .chat-home-hero p,
#zav-chat.chat-theme-light .chat-home-action-sub,
#zav-chat.chat-theme-light .chat-trust-line,
#zav-chat.chat-theme-light .message-time {
    color: #667085;
}

#zav-chat.chat-theme-light .chat-response-pill {
    border-color: #d0d5dd;
    background: #eef2f6;
    color: #475467;
}

#zav-chat.chat-theme-light .chat-response-pill strong {
    color: #111827;
}

#zav-chat.chat-theme-light .chat-home-search-cta {
    border-color: #d0d5dd;
    background: #ffffff;
    color: #334155;
}

#zav-chat.chat-theme-light .chat-home-card {
    border-color: #d0d5dd;
    background: #ffffff;
}

#zav-chat.chat-theme-light .chat-home-card h5,
#zav-chat.chat-theme-light .chat-home-action-title {
    color: #111827;
}

#zav-chat.chat-theme-light .chat-home-action {
    border-top-color: #eaecf0;
}

#zav-chat.chat-theme-light .chat-home-action::after {
    color: #667085;
}

#zav-chat.chat-theme-light .chat-messages {
    background: transparent;
}

#zav-chat.chat-theme-light .chat-message.bot .message-content {
    background: #ffffff;
    border-color: #d0d5dd;
    color: #111827;
}

#zav-chat.chat-theme-light .chat-message.user .message-content {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.38);
    color: #065f46;
}

#zav-chat.chat-theme-light .chat-quick-actions .quick-action {
    border-color: #d0d5dd;
    background: #ffffff;
    color: #334155;
}

#zav-chat.chat-theme-light .chat-quick-actions .quick-action:hover {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.08);
    color: #065f46;
}

#zav-chat.chat-theme-light .chat-input-container {
    background: rgba(255, 255, 255, 0.95);
    border-top-color: #e4e7ec;
}

#zav-chat.chat-theme-light .chat-input-wrapper {
    background: #ffffff;
    border-color: #d0d5dd;
}

#zav-chat.chat-theme-light .chat-input {
    color: #111827;
}

#zav-chat.chat-theme-light .chat-input::placeholder {
    color: #6b7280;
}

#zav-chat.chat-theme-light .chat-send {
    color: #059669;
}
