/* ========================================================================
   My AI Chatbot — Modern CSS v2.1 (2026)
   - Mobile-first responsive design
   - WCAG 2.1 AA compliant
   - Optimized performance
   - Professional UI polish
   ======================================================================== */

/* ========================================================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ======================================================================== */

   .maic-chatbot-container {
    /* Core Layout */
    --maic-z-index: 9999;
    --maic-radius: 16px;
    --maic-radius-sm: 8px;
    --maic-radius-bubble: 18px;
    --maic-gap: 16px;
    --maic-gap-sm: 12px;
    
    /* Typography */
    --maic-font-size-base: 15px;
    --maic-font-size-sm: 13px;
    --maic-font-size-xs: 11px;
    --maic-line-height: 1.5;
    
    /* Spacing */
    --maic-spacing-xs: 4px;
    --maic-spacing-sm: 8px;
    --maic-spacing-md: 12px;
    --maic-spacing-lg: 16px;
    --maic-spacing-xl: 20px;
    
    /* Shadows (Elevation System) */
    --maic-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --maic-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --maic-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --maic-shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.18);

    /* Blur */
    --maic-blur-glass: blur(16px); /* Стандартное значение Glassmorphism */
    
    /* Transitions */
    --maic-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --maic-transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --maic-transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Touch Targets */
    --maic-touch-target: 48px;
    --maic-touch-target-sm: 44px;
    
    /* Default Theme Variables (Light - will be overridden by themes) */
    --maic-bg: #ffffff;
    --maic-bg-elevated: #ffffff;
    --maic-fg: #1a1a1a;
    --maic-fg-secondary: #666666;
    --maic-border: #e0e0e0;
    
    --maic-user-bg: #0066cc;
    --maic-user-fg: #ffffff;
    --maic-bot-bg: #f5f5f5;
    --maic-bot-fg: #1a1a1a;
    --maic-error-bg: #ffebee;
    --maic-error-fg: #c62828;
    
    --maic-accent: #0066cc;
    --maic-accent-hover: #0052a3;

    --maic-link: #7c3aed;
    --maic-link-hover: #6d28d9;
    
    /* Position */
    position: fixed;
    z-index: var(--maic-z-index);
    pointer-events: none; /* Allow click-through container */
  }
  
  /* ========================================================================
     2. POSITIONING
     ======================================================================== */
  
  /* Desktop positioning */
  .maic-position-right-bottom {
    bottom: 24px;
    right: 24px;
    left: auto;
    top: auto;
  }
  
  .maic-position-left-bottom {
    bottom: 24px;
    left: 24px;
    right: auto;
    top: auto;
  }
  
  /* RTL Support */
  [dir="rtl"] .maic-position-right-bottom {
    right: auto;
    left: 24px;
  }
  
  [dir="rtl"] .maic-position-left-bottom {
    left: auto;
    right: 24px;
  }
  
  /* Mobile positioning (smaller offset) */
  @media (max-width: 768px) {
    .maic-position-right-bottom,
    .maic-position-left-bottom {
      bottom: 16px;
      right: 16px;
      left: auto;
    }
    
    .maic-position-left-bottom {
      left: 16px;
      right: auto;
    }
  }
  
  /* ========================================================================
     3. OVERLAY & BODY LOCK
     ======================================================================== */
  
     .maic-overlay {
      position: fixed;
      inset: 0;
    
      /* мягкое затемнение + сильный blur */
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px); /* Safari / iOS */
      z-index: 9998;
    
      opacity: 0;
      pointer-events: auto;
      transition: opacity var(--maic-transition-base);
    }
    
  
  .maic-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
  
  body.maic-no-scroll {
    overflow: hidden;
    /* iOS fix */
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    right: 0;
  }

  /* Blur всей страницы вокруг попапа / дока */
  body.maic-no-scroll > *:not(.maic-chatbot-container):not(.maic-overlay) {
    filter: blur(6px);
    transition: filter var(--maic-transition-base);
    background: rgba(3, 7, 18, 0.55);
  }

  /* ========================================================================
     4. POPUP CONTAINER (Shared Shell)
     ======================================================================== */
  
  #maic-chatbot-popup {
    display: none;
    flex-direction: column;
    width: min(440px, calc(100vw - 32px));
    width: 820px;
    max-height: min(680px, calc(100vh - 20px));
    border-radius: var(--maic-radius);
    background: var(--maic-bg);
    color: var(--maic-fg);
    box-shadow: var(--maic-shadow-xl);
    overflow: hidden;
    pointer-events: auto; /* Re-enable clicks */
    transition: transform var(--maic-transition-base), opacity var(--maic-transition-base);
    backdrop-filter: var(--maic-blur-glass);
    -webkit-backdrop-filter: var(--maic-blur-glass);
  }
  
  /* Visibility States */
  #maic-chatbot-popup.is-open {
    display: flex;
  }
  
  /* ========================================================================
     5. DISPLAY MODES
     ======================================================================== */
  
  /* Popup Mode: Centered with entrance animation */
  #maic-chatbot-popup.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: maicSlideUp var(--maic-transition-slow);
  }
  
  @keyframes maicSlideUp {
    from {
      opacity: 0;
      transform: translate(-50%, calc(-50% + 20px));
    }
    to {
      opacity: 1;
      transform: translate(-50%, -50%);
    }
  }

    /* Close (reverse of maicSlideUp) */
  #maic-chatbot-popup.popup.is-closing{
    animation: maicSlideDown var(--maic-transition-slow);
    animation-fill-mode: both;
    pointer-events: none;
  }

  @keyframes maicSlideDown {
    from {
      opacity: 1;
      transform: translate(-50%, -50%);
    }
    to {
      opacity: 0;
      transform: translate(-50%, calc(-50% + 20px));
    }
  }
  
  /* Dock Mode: Bottom corner */
  #maic-chatbot-popup.dock {
    position: fixed;
    right: 24px;
    bottom: 24px;
    left: auto;
    top: auto;
    max-height: calc(100vh - 48px);
    animation: maicSlideInRight var(--maic-transition-slow);
  }
  
  @keyframes maicSlideInRight {
    from {
      opacity: 0;
      transform: translateX(20px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

    /* Close (reverse of maicSlideInRight) */
  #maic-chatbot-popup.dock.is-closing{
    animation: maicSlideOutRight var(--maic-transition-slow);
    animation-fill-mode: both;
    pointer-events: none;
  }

  @keyframes maicSlideOutRight {
    from {
      opacity: 1;
      transform: translateX(0);
    }
    to {
      opacity: 0;
      transform: translateX(20px);
    }
  }

  
  /* Inline Mode: Embedded in page */
  #maic-chatbot-popup.inline {
    position: static;
    width: 100%;
    max-width: 100%;
    max-height: 600px;
    display: flex !important;
    box-shadow: var(--maic-shadow-md);
    border: 1px solid var(--maic-border);
    animation: none;
  }
  
  /* ========================================================================
   6. HEADER (3-column layout: Clear | Title | Close)
   ======================================================================== */

  .maic-chatbot-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--maic-gap-sm);
    padding: var(--maic-gap-sm) var(--maic-gap);
    background: var(--maic-bg-elevated);
    box-shadow: 0 12px 18px -14px rgba(0,0,0,.45);
  }

  .maic-chatbot-title {
    margin: 0;
    color: var(--maic-fg);
    line-height: 1.3;
    text-align: center;
    grid-column: 2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  /* ========================================================================
    7. HEADER BUTTONS (Clear & Close)
    ======================================================================== */

  .maic-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--maic-transition-fast), 
                background var(--maic-transition-fast),
                opacity var(--maic-transition-fast);
    background: rgba(0, 0, 0, 0.05);
    color: var(--maic-fg-secondary);
    font-size: 16px;
  }

  .maic-header-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
  }

  .maic-header-btn:active {
    transform: scale(0.98);
  }

  .maic-header-btn:focus-visible {
    outline: 2px solid var(--maic-accent);
    outline-offset: 2px;
  }

  .maic-header-btn i {
    font-size: 16px;
    line-height: 1;
    pointer-events: none;
  }

  /* Clear button specific */
  #maic-chatbot-clear.maic-header-btn {
    grid-column: 1;
  }

  /* Close button specific */
  #maic-chatbot-close.maic-header-btn {
    grid-column: 3;
    color: #dc3545;
  }

  #maic-chatbot-close.maic-header-btn:hover {
    background: rgba(220, 53, 69, 0.1);
  }
  
  /* ========================================================================
     8. MESSAGES AREA
     ======================================================================== */
  
	  .maic-chatbot-messages {
	    /* Top gap when JS pins the user's message at the top */
	    --maic-user-anchor-gap: 8px;
	    display: flex;
	    flex-direction: column;
	    flex: 1;
	    min-height: 0; /* Critical for flex scroll */
	    padding: var(--maic-gap);
    gap: var(--maic-spacing-md);
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
  }
  
  .maic-chatbot-messages::-webkit-scrollbar {
    width: 6px;
  }
  
  .maic-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .maic-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
  }
  
  .maic-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
  }
  
  /* ========================================================================
     9. MESSAGE BUBBLES
     ======================================================================== */
  
  .maic-message-user,
  .maic-message-bot,
  .maic-message-error {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--maic-radius-bubble);
    font-size: var(--maic-font-size-base);
    line-height: var(--maic-line-height);
    word-break: break-word;
    /*white-space: pre-wrap;*/
    box-shadow: var(--maic-shadow-sm);
    animation: maicMessageFadeIn var(--maic-transition-base);
  }
  
  @keyframes maicMessageFadeIn {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* User Messages (Right-aligned) */
  .maic-message-user {
    align-self: flex-end;
    background: var(--maic-user-bg);
    color: var(--maic-user-fg);
    border-bottom-right-radius: 4px;
  }
  
  /* Bot Messages (Left-aligned) */
  .maic-message-bot {
    align-self: flex-start;
    background: var(--maic-bot-bg);
    color: var(--maic-bot-fg);
    border-bottom-left-radius: 4px;
  }
  
  /* Error Messages */
  .maic-message-error {
    align-self: flex-start;
    background: var(--maic-error-bg);
    color: var(--maic-error-fg);
    border-left: 3px solid var(--maic-error-fg);
  }
  
  /* Loading Indicator */
  .maic-message-bot.maic-loading {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px;
  }
  
  .maic-message-bot.maic-loading::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: maicDotPulse 1.4s infinite ease-in-out;
    animation-delay: 0.16s;
  }
  
  @keyframes maicDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
  }
  
  /* ========================================================================
   10. INPUT AREA (Updated with inline Send button)
   ======================================================================== */

  .maic-chatbot-input-area {
    display: flex;
    flex-direction: column;
    gap: var(--maic-spacing-sm);
    padding: var(--maic-gap-sm) var(--maic-gap) var(--maic-gap);
    background: var(--maic-bg-elevated);
    box-shadow: 0 -12px 18px -14px rgba(0,0,0,.25);
  }

  /* Input wrapper: flexbox for input + send button */
  .maic-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
  }

  /* Textarea Input */
  #maic-chatbot-input {
    flex: 1;
    min-height: var(--maic-touch-target);
    max-height: 120px;
    padding: 12px 16px;
    margin-right: 8px;
    border: 1px solid var(--maic-border);
    border-radius: var(--maic-radius-sm);
    background: var(--maic-bg);
    color: var(--maic-fg);
    font-size: var(--maic-font-size-base);
    line-height: var(--maic-line-height);
    font-family: inherit;
    resize: none;
    overflow-y: hidden;
    transition: border-color var(--maic-transition-fast), 
                box-shadow var(--maic-transition-fast);
    box-sizing: border-box;
  }

  #maic-chatbot-input:focus {
    outline: none;
    border-color: var(--maic-accent);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
  }

  #maic-chatbot-input::placeholder {
    color: var(--maic-fg-secondary);
    opacity: 0.6;
  }

  /* Info Text */
  .maic-chatbot-info {
    margin: 0;
    font-size: var(--maic-font-size-xs);
    color: var(--maic-fg-secondary);
    text-align: center;
    line-height: 1.4;
  }

  /* ========================================================================
    11. SEND BUTTON (Inline with input)
    ======================================================================== */

  #maic-chatbot-send.maic-inline-send {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--maic-touch-target);
    min-height: var(--maic-touch-target);
    border: none;
    border-radius: 50%;
    cursor: not-allowed;
    transition: transform var(--maic-transition-fast), 
                box-shadow var(--maic-transition-fast),
                background var(--maic-transition-fast);
    background: rgba(0, 0, 0, 0.05);
    color: rgba(255, 255, 255, 0.8);
    pointer-events: auto;
  }

  /* Focus Indicators */
  #maic-chatbot-send.maic-inline-send:focus-visible {
    outline: 2px solid var(--maic-accent);
    outline-offset: 2px;
  }

  /* Button Icon */
  #maic-chatbot-send.maic-inline-send i {
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
  }

  /* Active State */
  #maic-chatbot-send.maic-inline-send.active {
    background: linear-gradient(135deg, var(--maic-accent), var(--maic-accent-hover));
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
  }

  #maic-chatbot-send.maic-inline-send.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
  }

  #maic-chatbot-send.maic-inline-send.active:active {
    transform: translateY(0);
  }

  /* Loading State */
  #maic-chatbot-send.maic-inline-send.loading {
    background: rgba(0, 0, 0, 0.1);
    cursor: wait;
    pointer-events: none;
  }
  
  /* ========================================================================
     12. TOGGLE BUTTON (Floating)
     ======================================================================== */
  
  .maic-chatbot-toggle {
    background: var(--maic-accent);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 24px;
    pointer-events: auto;
    border: 1px var(--maic-accent) solid;
    border-radius: 50%;
    padding: 10px;
  }

  /* SVG icon inside toggle */
  .maic-chatbot-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* чтобы SVG красиво вписался в круглую кнопку */
  .maic-chatbot-toggle svg {
    display: block;
    width: 28px;
    height: 28px;
    pointer-events: none; /* клик по иконке всё равно попадает по кнопке */
  }

  /* запасной текстовый вариант, если SVG вдруг не загрузился */
  .maic-toggle-fallback {
    font-size: 22px;
    line-height: 1;
  }
  
  .maic-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  }
  
  .maic-chatbot-toggle:active {
    transform: scale(1.05);
  }
  
  /* Pulse Animation (Attention Grabber) */
  @keyframes maicPulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
    50% { box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4), 0 0 0 8px rgba(0, 102, 204, 0.1); }
  }
  
  .maic-chatbot-toggle.pulse {
    animation: maicPulse 2s ease-in-out infinite;
  }
  
  /* ========================================================================
     13. PRODUCT RESULTS (WooCommerce)
     ======================================================================== */
  
  .maic-product-result {
    display: flex;
    align-items: center;
    padding: var(--maic-spacing-sm);
    margin-bottom: var(--maic-spacing-sm);
    border: 1px solid var(--maic-border);
    border-radius: var(--maic-radius-sm);
    background: var(--maic-bg);
    font-size: var(--maic-font-size-sm);
    transition: box-shadow var(--maic-transition-fast);
  }
  
  .maic-product-result:hover {
    box-shadow: var(--maic-shadow-sm);
  }
  
  .maic-product-result img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: var(--maic-spacing-md);
  }
  
  .maic-product-result a {
    display: flex;
    align-items: center;
    color: var(--maic-link);
    text-decoration: none;
    flex: 1;
  }
  
  .maic-product-result a:hover {
    text-decoration: underline;
  }
  
  /* ========================================================================
     14. MOBILE OPTIMIZATIONS
     ======================================================================== */
  
  @media (max-width: 768px) {
    /* Tighten spacing on mobile to free up vertical space */
    .maic-chatbot-container {
      --maic-gap: 8px;
      --maic-gap-sm: 8px;
      --maic-spacing-md: 10px;
      --maic-spacing-sm: 8px;
    }

    /* Full-width on mobile */
    #maic-chatbot-popup.popup,
    #maic-chatbot-popup.dock {

      width: calc(100vw - 32px);
      max-width: none;
      height: calc(100vh - 100px);
      max-height: calc(100vh - 100px);
    }

    #maic-chatbot-popup.popup {
      width: min(440px, calc(100vw - 32px));
      max-height: min(680px, calc(100vh - 20px));
      max-height: calc(100vh - 40px);
    }
    
    /* Larger touch targets */
    #maic-chatbot-send,
    #maic-chatbot-clear,
    #maic-chatbot-close,
    .maic-chatbot-toggle {
      min-width: var(--maic-touch-target);
      min-height: var(--maic-touch-target);
    }
    
    /* Larger text for readability */
    .maic-message-user,
    .maic-message-bot {
      font-size: 15px;
    }
    
    /* Safe area for notched devices */
    #maic-chatbot-popup {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
  
  /* Small phones (iPhone SE) */
  @media (max-width: 375px) {
    /* Extra-tight spacing for small phones */
    .maic-chatbot-container {
      --maic-gap: 10px;
      --maic-gap-sm: 6px;
      --maic-spacing-md: 8px;
      --maic-spacing-sm: 6px;
    }

    #maic-chatbot-popup {
      height: calc(100vh - 80px);
    }
    
    .maic-chatbot-header {
      gap: var(--maic-gap-sm);
      padding: var(--maic-gap-sm) var(--maic-gap);
    }

    .maic-message-user,
    .maic-message-bot {
      max-width: 85%;
    }
  }
  
  /* Landscape orientation */
  @media (max-height: 500px) and (orientation: landscape) {
    #maic-chatbot-popup {
      max-height: calc(100vh - 40px);
    }
  }
  
  /* ========================================================================
     15. THEME: LIGHT (Default)
     ======================================================================== */
  
  .maic-chatbot-container.maic-theme-light {
    --maic-bg: #ffffff;
    --maic-bg-elevated: #ffffff;
    --maic-fg: #1a1a1a;
    --maic-fg-secondary: #666666;
    --maic-border: #e0e0e0;
    
    --maic-user-bg: #0066cc;
    --maic-user-fg: #ffffff;
    --maic-bot-bg: #f5f5f5;
    --maic-bot-fg: #1a1a1a;
    --maic-error-bg: #ffebee;
    --maic-error-fg: #c62828;
    
    --maic-accent: #0066cc;
    --maic-accent-hover: #0052a3;
    
    --maic-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --maic-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --maic-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --maic-shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.18);
  }
  
  /* Light theme specific overrides */
  .maic-theme-light #maic-chatbot-input {
    background: #ffffff;
    color: #1a1a1a;
    border-color: #e0e0e0;
  }
  
  .maic-theme-light #maic-chatbot-clear {
    background: #f7f7f7;
    color: #666666;
    border-color: #e0e0e0;
  }
  
  .maic-theme-light #maic-chatbot-clear:hover {
    background: #efefef;
  }

    /* Light theme btn*/
  .maic-theme-light .maic-header-btn {
    background: #f7f7f7;
    color: #666666;
  }

  .maic-theme-light .maic-header-btn:hover {
    background: #efefef;
  }
  
  /* ========================================================================
     16. THEME: DARK (Modern)
     ======================================================================== */
  
  .maic-chatbot-container.maic-theme-dark {
    --maic-bg: #1e1e1e;
    --maic-bg-elevated: #2a2a2a;
    --maic-fg: #e1e1e1;
    --maic-fg-secondary: #b0b0b0;
    --maic-border: rgba(255, 255, 255, 0.08);
    
    --maic-user-bg: #0066cc;
    --maic-user-fg: #ffffff;
    --maic-bot-bg: #2a2a2a;
    --maic-bot-fg: #e1e1e1;
    --maic-error-bg: #5c1a1a;
    --maic-error-fg: #ef5350;
    
    --maic-accent: #1a8fff;
    --maic-accent-hover: #0066cc;
    
    --maic-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --maic-shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
    --maic-shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.5);
    --maic-shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.6);
  }
  
  /* Dark theme specific overrides */
  .maic-theme-dark #maic-chatbot-input {
    background: #1e1e1e;
    color: #e1e1e1;
    border-color: rgba(255, 255, 255, 0.12);
  }
  
  .maic-theme-dark #maic-chatbot-input:focus {
    border-color: var(--maic-accent);
    box-shadow: 0 0 0 3px rgba(26, 143, 255, 0.15);
  }
  
  .maic-theme-dark #maic-chatbot-clear {
    background: #2a2a2a;
    color: #b0b0b0;
    border-color: rgba(255, 255, 255, 0.08);
  }
  
  .maic-theme-dark #maic-chatbot-clear:hover {
    background: #333333;
  }
  
  .maic-theme-dark .maic-product-result {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.08);
  }
  
  /* Dark theme scrollbar */
  .maic-theme-dark .maic-chatbot-messages {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  }
  
  .maic-theme-dark .maic-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
  }

  /* Dark theme btn*/
  .maic-theme-dark .maic-header-btn {
    background: #2a2a2a;
    color: #b0b0b0;
  }

  .maic-theme-dark .maic-header-btn:hover {
    background: #333333;
  }
  
  /* ========================================================================
     17. THEME: PREMIUM (Modern Glassmorphism)
     ======================================================================== */
  
  .maic-chatbot-container.maic-theme-premium {
    --maic-bg: rgba(15, 15, 20, 0.68);
    --maic-bg-elevated: rgba(30, 30, 40, 0.6);
    --maic-fg: #f0f0f0;
    --maic-fg-secondary: #b8b8b8;
    --maic-border: rgba(124, 58, 237, 0.2);
    
    --maic-accent: #7c3aed;
    --maic-accent-hover: #6d28d9;
    
    --maic-user-bg: #f5f5f5;
    --maic-user-fg: #1a1a1a;
    --maic-bot-bg: rgba(124, 58, 237, 0.12);
    --maic-bot-fg: #f0f0f0;
    --maic-error-bg: rgba(239, 68, 68, 0.15);
    --maic-error-fg: #fca5a5;
    
    --maic-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --maic-shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5);
    --maic-shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.6);
    --maic-shadow-xl: 0 0 1px rgba(124, 58, 237, 0.5), 
                       0 16px 40px rgba(0, 0, 0, 0.7);
  }
  
  /* Glassmorphism effect */
  .maic-theme-premium #maic-chatbot-popup {
    background:
      linear-gradient(
        135deg,
        rgba(15, 15, 25, 0.78),
        rgba(35, 25, 60, 0.62)
      );
    backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(124, 58, 237, 0.35);
    box-shadow:
      0 0 1px rgba(124, 58, 237, 0.55),
      0 18px 46px rgba(0, 0, 0, 0.85);
  }

  /* Premium theme input */
  .maic-theme-premium #maic-chatbot-input {
    background: rgba(30, 30, 40, 0.6);
    color: #f0f0f0;
    border-color: rgba(124, 58, 237, 0.25);
    backdrop-filter: blur(8px);
  }
  
  .maic-theme-premium #maic-chatbot-input:focus {
    border-color: var(--maic-accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
  }
  
  .maic-theme-premium #maic-chatbot-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
  }
  
  /* Premium scrollbar */
  .maic-theme-premium .maic-chatbot-messages {
    scrollbar-color: rgba(124, 58, 237, 0.3) transparent;
  }
  
  .maic-theme-premium .maic-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.3);
  }
  
  .maic-theme-premium .maic-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 58, 237, 0.5);
  }
  
  /* Premium info text */
  .maic-theme-premium .maic-chatbot-info {
    color: rgba(255, 255, 255, 0.6);
  }

  /* Premium theme btn*/
  .maic-theme-premium .maic-header-btn {
    background: rgba(255, 255, 255, 0.06);
    color: #f0f0f0;
    backdrop-filter: blur(8px) saturate(140%);
  }

  .maic-theme-premium .maic-header-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.3);
  }

  .maic-theme-premium #maic-chatbot-send.maic-inline-send.active {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    box-shadow: 0 0 16px rgba(124, 58, 237, 0.4);
  }

  .maic-theme-premium #maic-chatbot-send.maic-inline-send.active:hover {
    box-shadow: 
      0 0 24px rgba(124, 58, 237, 0.6),
      0 4px 12px rgba(0, 0, 0, 0.4);
  }

  /* ========================================================================
   18. NEON theme (VolHan legacy neon)
   ======================================================================== */

  .maic-chatbot-container.maic-theme-neon {
    --maic-bg: rgba(15, 15, 25, .20);
    --maic-bg-elevated: rgba(15, 15, 25, .35);
    --maic-fg: #ffffff;
    --maic-fg-secondary: #d0d0d0;
    --maic-border: rgba(107, 107, 107, 0.30);
    --maic-user-bg: #fff;
    --maic-user-fg: #000000;
    --maic-bot-bg: #c9c6f8;
    --maic-bot-fg: #000000;

    /* старые err-переменные адаптированы под v2 */
    --maic-error-bg: #ffe8e8;
    --maic-error-fg: #d8000c;

    /* неоновый акцент берём из твоего градиента */
    --maic-accent: #9d00ff;
    --maic-accent-hover: #00fff0;

    --maic-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  }

  .maic-chatbot-container.maic-theme-neon .maic-chatbot-header {
    background: none;
    border-radius: 16px 16px 0  0;
  }

  .maic-chatbot-container.maic-theme-neon .maic-chatbot-input-area {
    background: none;
    border-radius:  0  0 16px 16px;
  }

  /* стекло + неоновая рамка вокруг попапа */
  .maic-chatbot-container.maic-theme-neon #maic-chatbot-popup {
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    overflow: visible; /* нужно для ::before */
  }

  .maic-chatbot-container.maic-theme-neon #maic-chatbot-popup::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: var(--maic-radius);
    background: linear-gradient(
      135deg,
      #00fff0,
      #9d00ff,
      #00a3ff,
      #6a00ff,
      #00fff0
    );
    background-size: 400% 400%;
    animation: maicNeonBorder 8s ease infinite;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: -1;
  }

  @keyframes maicNeonBorder {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }

  /* ========================================================================
   NEON — Toggle button as Glass Glowing Orb (override base toggle)
   ======================================================================== */

  .maic-chatbot-container.maic-theme-neon .maic-chatbot-toggle,
  .maic-chatbot-container.maic-theme-neon #maic-chatbot-toggle{
    /* жёсткий reset (чтобы тема/Elementor не вмешивались) */
    -webkit-appearance: none;
    appearance: none;
    padding: 10px;
    margin: 0;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    border-radius: 999px;

    /* стекло + неон */
    background:
      radial-gradient(circle at 28% 22%, rgba(255,255,255,.55), rgba(255,255,255,0) 42%),
      radial-gradient(circle at 72% 80%, rgba(0,255,240,.28), rgba(0,0,0,0) 58%),
      linear-gradient(135deg, rgba(0,255,240,.92), rgba(157,0,255,.92));

    backdrop-filter: blur(10px) saturate(170%);
    -webkit-backdrop-filter: blur(10px) saturate(170%);

    box-shadow:
      0 14px 30px rgba(0,0,0,.38),
      0 0 0 1px rgba(255,255,255,.08) inset,
      0 0 24px rgba(0,255,240,.40),
      0 0 34px rgba(157,0,255,.32);

    position: relative;
    overflow: hidden;
    isolation: isolate;

    transform: translateZ(0);
  }

  /* глянец сверху */
  .maic-chatbot-container.maic-theme-neon .maic-chatbot-toggle::before,
  .maic-chatbot-container.maic-theme-neon #maic-chatbot-toggle::before{
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: radial-gradient(circle at 30% 28%, rgba(122, 249, 147, 0.6), rgba(255,255,255,0) 46%);
    opacity: .95;
    z-index: 0;
    pointer-events: none;
  }

  /* лёгкая тень снизу внутри шара */
  .maic-chatbot-container.maic-theme-neon .maic-chatbot-toggle::after,
  .maic-chatbot-container.maic-theme-neon #maic-chatbot-toggle::after{
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 120%, rgba(0,0,0,.45), rgba(0,0,0,0) 58%);
    opacity: .85;
    z-index: 0;
    pointer-events: none;
  }

  /* иконка поверх слоёв */
  .maic-chatbot-container.maic-theme-neon .maic-chatbot-toggle > *,
  .maic-chatbot-container.maic-theme-neon #maic-chatbot-toggle > *{
    position: relative;
    z-index: 1;
  }


  /* hover / active */
  @media (hover:hover) and (pointer:fine){
    .maic-chatbot-container.maic-theme-neon .maic-chatbot-toggle:hover,
    .maic-chatbot-container.maic-theme-neon #maic-chatbot-toggle:hover{
      transform: translateY(-1px) scale(1.06);
      box-shadow:
        0 18px 40px rgba(0,0,0,.45),
        0 0 0 1px rgba(255,255,255,.10) inset,
        0 0 30px rgba(0,255,240,.55),
        0 0 42px rgba(157,0,255,.42);
    }
  }

  .maic-chatbot-container.maic-theme-neon .maic-chatbot-toggle:active,
  .maic-chatbot-container.maic-theme-neon #maic-chatbot-toggle:active{
    transform: scale(1.03);
  }

  .maic-chatbot-container.maic-theme-neon .maic-chatbot-title.fade-up {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity .5s, transform .5s;
  }

  /* Neon theme */
  .maic-theme-neon .maic-header-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px) saturate(140%);
  }

  .maic-theme-neon .maic-header-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 15px rgba(157, 0, 255, 0.4);
  }

  .maic-theme-neon #maic-chatbot-send.maic-inline-send {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px) saturate(140%);
  }

  .maic-theme-neon #maic-chatbot-send.maic-inline-send.active {
    background: linear-gradient(135deg, #00fff0, #9d00ff);
    box-shadow:
      0 0 15px rgba(0, 255, 240, 0.4),
      0 0 25px rgba(157, 0, 255, 0.3),
      0 0 35px rgba(0, 255, 240, 0.25);
  }

  .maic-theme-neon #maic-chatbot-send.maic-inline-send.active:hover {
    box-shadow:
      0 0 25px rgba(157, 0, 255, 0.6),
      0 0 45px rgba(0, 255, 240, 0.55),
      0 0 55px rgba(157, 0, 255, 0.45);
    transform: translateY(-1px);
  }

  .maic-theme-neon #maic-chatbot-send.maic-inline-send.loading {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2) inset;
  }
  /* инпут и инфо */

  .maic-chatbot-container.maic-theme-neon #maic-chatbot-input {
    border: 1px solid #c9c6f8;
  }

  .maic-chatbot-container.maic-theme-neon #maic-chatbot-input:focus {
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.4);
    border: 1px solid #9d00ff;
  }

  .maic-chatbot-container.maic-theme-neon {
    color: #454545;
    margin: 0 auto;
  }

  .maic-chatbot-info {
    color: #f7f7f7;
    margin: 0 auto;
  }

  /* аккуратный неоновый скроллбар */
  .maic-chatbot-container.maic-theme-neon .maic-chatbot-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 58, 237, 0.8) transparent;
  }

  .maic-chatbot-container.maic-theme-neon .maic-chatbot-messages::-webkit-scrollbar {
    width: 4px;
  }

  .maic-chatbot-container.maic-theme-neon .maic-chatbot-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 10px;
  }

  /* responsive под неон */

  @media (max-width: 768px) {
    .maic-chatbot-container.maic-theme-neon #maic-chatbot-popup {
      min-height: 400px;
      padding: 10px;
    }
  }

  @media (max-width: 480px) {
    .maic-chatbot-container.maic-theme-neon #maic-chatbot-popup {
      min-height: 350px;
      padding: 8px;
    }

    .maic-chatbot-container.maic-theme-neon .maic-message-user,
    .maic-chatbot-container.maic-theme-neon .maic-message-bot {
      font-size: var(--maic-font-size-base);
    }
  }

  @media (max-width: 375px) {
    .maic-chatbot-container.maic-theme-neon #maic-chatbot-popup {
      padding: 6px;
    }
  }

  /* ========================================================================
     19. ACCESSIBILITY ENHANCEMENTS
     ======================================================================== */
  
  /* Reduced motion support (scoped to MAIC only) */
  @media (prefers-reduced-motion: reduce) {
    .maic-chatbot-container *,
    .maic-chatbot-container *::before,
    .maic-chatbot-container *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .maic-chatbot-container {
      --maic-border: currentColor;
    }
    
    #maic-chatbot-popup {
      border: 2px solid currentColor;
    }
    
    .maic-message-user,
    .maic-message-bot {
      border: 1px solid currentColor;
    }
  }
  
  /* Focus visible (keyboard navigation) */
  .maic-chatbot-messages:focus-visible {
    outline: 2px solid var(--maic-accent);
    outline-offset: -2px;
  }
  
  /* Screen reader only text */
  .maic-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
  
  /* ========================================================================
     20. PRINT STYLES
     ======================================================================== */
  
  @media print {
    .maic-chatbot-container,
    .maic-overlay {
      display: none !important;
    }
  }
  
  /* ========================================================================
     21. UTILITY CLASSES
     ======================================================================== */
  
  /* Hide toggle in inline mode */
  #maic-chatbot-popup.inline ~ .maic-chatbot-toggle {
    display: none;
  }
  
  /* Disabled state */
  .maic-chatbot-container.is-disabled {
    pointer-events: none;
    opacity: 0.5;
  }
  
  /* Loading state for entire widget */
  .maic-chatbot-container.is-loading {
    cursor: wait;
  }
  
  /* ========================================================================
     22. ANIMATION POLISH
     ======================================================================== */
  
  /* Smooth page transitions */
  #maic-chatbot-popup {
    will-change: transform, opacity;
  }
  
  /* Optimize animations */
  .maic-message-user,
  .maic-message-bot,
  .maic-message-error {
    will-change: transform, opacity;
  }
  
  /* Prevent animation flicker */
  #maic-chatbot-popup.is-open {
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* ========================================================================
     23. DARK MODE MEDIA QUERY SUPPORT (Auto-detect)
     ======================================================================== */
  
  /* Auto switch to dark theme if no explicit theme is set */
  @media (prefers-color-scheme: dark) {
    .maic-chatbot-container:not(.maic-theme-light):not(.maic-theme-dark):not(.maic-theme-premium):not(.maic-theme-neon) {
      --maic-bg: #1e1e1e;
      --maic-bg-elevated: #2a2a2a;
      --maic-fg: #e1e1e1;
      --maic-fg-secondary: #b0b0b0;
      --maic-border: rgba(255, 255, 255, 0.08);
      
      --maic-user-bg: #0066cc;
      --maic-user-fg: #ffffff;
      --maic-bot-bg: #2a2a2a;
      --maic-bot-fg: #e1e1e1;
      
      --maic-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
      --maic-shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
      --maic-shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.5);
      --maic-shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.6);
    }
  }
  
  /* ========================================================================
     24. PERFORMANCE OPTIMIZATIONS
     ======================================================================== */
  
  /* GPU acceleration for animated elements */
  #maic-chatbot-send,
  #maic-chatbot-clear,
  #maic-chatbot-close,
  .maic-chatbot-toggle {
    transform: translateZ(0);
    backface-visibility: hidden;
  }
  
  /* Optimize repaints */
  .maic-chatbot-messages {
    contain: layout style paint;
  }
  
  /* ========================================================================
     25. BROWSER COMPATIBILITY FIXES
     ======================================================================== */
  
  /* Safari safe-area support */
  @supports (padding: env(safe-area-inset-bottom)) {
    .maic-chatbot-input-area {
      padding-bottom: calc(var(--maic-gap) + env(safe-area-inset-bottom));
    }
  }
  
  /* Firefox scrollbar fix */
  @-moz-document url-prefix() {
    .maic-chatbot-messages {
      scrollbar-width: thin;
    }
  }
  
  /* IE11 fallback (graceful degradation) */
  @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    #maic-chatbot-popup {
      border: 1px solid #ccc;
    }
    
    .maic-message-user,
    .maic-message-bot {
      max-width: 70%;
    }
  }
  
  /* ========================================================================
     26. EDGE CASES & BUG FIXES
     ======================================================================== */
  
  /* Fix for iOS zoom on input focus */
  @supports (-webkit-touch-callout: none) {
    #maic-chatbot-input {
      font-size: 16px; /* Prevents zoom on iOS */
    }
  }
  
  /* Fix for Android chrome address bar overlap */
  /*-------- Old Claude 
  @media (max-width: 768px) {
    #maic-chatbot-popup {
      height: 100dvh; // Dynamic viewport height
      max-height: 100dvh;
    }
  }*/

  /* ChatGPT - Так мы не ломаем inline-режим внутри контента.*/
  @media (max-width: 768px) {
    #maic-chatbot-popup.popup,
    #maic-chatbot-popup.dock {
      height: 90dvh; /* Dynamic viewport height */
      max-height: 90dvh;
    }
  }

  
  /* Fix for Samsung Internet browser */
  @supports (-webkit-appearance: none) {
    .maic-chatbot-toggle {
      -webkit-tap-highlight-color: transparent;
    }
  }
  
  /* Prevent text selection on buttons */
  #maic-chatbot-send,
  #maic-chatbot-clear,
  #maic-chatbot-close,
  .maic-chatbot-toggle {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  /* ========================================================================
     27. CUSTOM SCROLLBAR FOR WEBKIT (Enhanced)
     ======================================================================== */
  
  /* Light theme scrollbar */
  .maic-theme-light .maic-chatbot-messages::-webkit-scrollbar {
    width: 8px;
  }
  
  .maic-theme-light .maic-chatbot-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
  }
  
  .maic-theme-light .maic-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
  }
  
  .maic-theme-light .maic-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
  }
  
  /* ========================================================================
     28. LOADING SPINNER (Enhanced)
     ======================================================================== */
  
  /* Three dots loading animation */
  .maic-message-bot.maic-loading {
    position: relative;
  }
  
  .maic-message-bot.maic-loading::before,
  .maic-message-bot.maic-loading::after {
    content: '';
    position: relative;
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: maicDotPulse 1.4s infinite ease-in-out;
  }
  
  .maic-message-bot.maic-loading::before {
    animation-delay: 0s;
  }
  
  .maic-message-bot.maic-loading::after {
    animation-delay: 0.32s;
  }
  
  /* ========================================================================
     29. HOVER STATES (Desktop Only)
     ======================================================================== */
  
  @media (hover: hover) and (pointer: fine) {
    /* Button hover enhancements */
    #maic-chatbot-send.active:hover,
    #maic-chatbot-clear:hover,
    #maic-chatbot-close:hover,
    .maic-chatbot-toggle:hover {
      transition-duration: 150ms;
      cursor: pointer;
    }
    
    /* Message hover (subtle highlight) */
    .maic-message-user:hover,
    .maic-message-bot:hover {
      box-shadow: var(--maic-shadow-md);
      transition: box-shadow 200ms ease;
    }
  }
  
  /* ========================================================================
     30. FINAL POLISH & EDGE CASES
     ======================================================================== */
  
  /* Prevent double-tap zoom on mobile */
  @media (max-width: 768px) {
    #maic-chatbot-send,
    #maic-chatbot-clear,
    #maic-chatbot-close,
    .maic-chatbot-toggle {
      touch-action: manipulation;
    }
  }
  
  /* Smooth font rendering */
  .maic-chatbot-container {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  
  /* Fix for flexbox gap in older browsers */
  @supports not (gap: 1px) {
    .maic-chatbot-messages > * + * {
      margin-top: var(--maic-spacing-md);
    }
  }

  /* =========================================================
   MAIC – Product Cards (theme-agnostic via CSS variables)
   ========================================================= */

/* 1) Base tokens (safe defaults). Any theme can override via .maic-theme-* class */
#maic-chatbot{
  --maic-surface: #ffffff;
  --maic-surface-2: #f6f7f9;
  --maic-text: #111111;
  --maic-muted: rgba(17,17,17,.72);
  --maic-border: rgba(0,0,0,.12);
  --maic-shadow: 0 10px 22px rgba(0,0,0,.08);
  --maic-radius: 14px;

  /* Accent tries Elementor globals first, then fallback */
  --maic-accent: var(--e-global-color-accent, var(--e-global-color-primary, #0b5cff));
  --maic-accent-contrast: #ffffff;

  --maic-btn-radius: 10px;
  --maic-focus: 0 0 0 3px rgba(11,92,255,.25);
}

/* Optional “dark-ish” themes (если у тебя есть такие классы — будут выглядеть лучше) */
#maic-chatbot.maic-theme-dark,
#maic-chatbot.maic-theme-black,
#maic-chatbot.maic-theme-night{
  --maic-surface: #14161a;
  --maic-surface-2: #1b1f25;
  --maic-text: #f1f3f5;
  --maic-muted: rgba(241,243,245,.75);
  --maic-border: rgba(255,255,255,.14);
  --maic-shadow: 0 12px 26px rgba(0,0,0,.35);
  --maic-focus: 0 0 0 3px rgba(11,92,255,.35);
}

/* 2) Product grid */
#maic-chatbot .maic-product-grid,
#maic-chatbot .maic-products-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

@media (max-width: 768px){
  #maic-chatbot .maic-message-user,
  #maic-chatbot .maic-message-bot,
  #maic-chatbot .maic-message-error{
    max-width: 95%;
  }

  #maic-chatbot .maic-product-grid,
  #maic-chatbot .maic-products-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }

  #maic-chatbot .maic-product-body{
    padding: 8px 9px 9px;
  }

  #maic-chatbot .maic-product-title{
    font-size: 13px;
    margin: 0 0 4px;
  }

  #maic-chatbot .maic-product-price{
    font-size: 12px;
    margin: 0 0 8px;
  }
}

/* 3) Card */
#maic-chatbot .maic-product-card{
  background: var(--maic-surface);
  color: var(--maic-text);
  border: 1px solid var(--maic-border);
  border-radius: var(--maic-radius);
  overflow:hidden;
  box-shadow: var(--maic-shadow);
}

#maic-chatbot .maic-product-media{
  display:block;
  background: var(--maic-surface-2);
  text-decoration:none;
  border-bottom: 1px solid var(--maic-border);
}
#maic-chatbot .maic-product-media img{
  width:100%;
  height:auto;
  max-height: 180px;
  object-fit: cover;
  display:block;
}

/* Body */
#maic-chatbot .maic-product-body{
  padding:10px 12px 12px;
}

#maic-chatbot .maic-product-title{
  display:block;
  font-weight:700;
  font-size:14px;
  line-height:1.25;
  margin:0 0 6px;
  color: inherit;
  text-decoration:none;
}
#maic-chatbot .maic-product-title:hover{
  text-decoration: underline;
}

#maic-chatbot .maic-product-price{
  font-size:13px;
  line-height:1.2;
  color: var(--maic-muted);
  margin:0 0 10px;
}

/* 4) Actions */
#maic-chatbot .maic-product-actions{
  display:flex;
  flex-direction: column-reverse;
  gap:8px;
  align-items:stretch;
}

#maic-chatbot .maic-product-actions .maic-btn{
  width: 100%;
}

@media (max-width: 768px){
  #maic-chatbot .maic-product-actions{
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  #maic-chatbot .maic-product-actions .maic-btn{
    width: 100%;
    padding: 7px 8px;
    font-size: 12px;
  }
}

/* Buttons (works as <a> and <button>) */
#maic-chatbot .maic-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  padding:9px 10px;
  border-radius: var(--maic-btn-radius);
  font-size:13px;
  line-height:1;
  cursor:pointer;
  text-decoration:none;
  user-select:none;

  border:1px solid var(--maic-border);
  background: transparent;
  color: inherit;

  transition: transform .06s ease, opacity .2s ease, background-color .2s ease, border-color .2s ease;
}
#maic-chatbot .maic-btn:active{ transform: translateY(1px); }
#maic-chatbot .maic-btn:focus{ outline:none; }
#maic-chatbot .maic-btn:focus-visible{ box-shadow: var(--maic-focus); }

#maic-chatbot .maic-btn-primary{
  background: var(--maic-accent);
  border-color: var(--maic-accent);
  color: var(--maic-accent-contrast);
}
#maic-chatbot .maic-btn-primary:hover{ opacity:.92; }

#maic-chatbot .maic-btn-secondary{
  background: transparent;
}
#maic-chatbot .maic-btn-secondary:hover{
  background: color-mix(in srgb, var(--maic-accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--maic-accent) 35%, var(--maic-border));
}

/* Loading/disabled */
#maic-chatbot .maic-btn.is-loading{
  opacity:.75;
  pointer-events:none;
}
#maic-chatbot .maic-btn:disabled{
  opacity:.6;
  cursor:not-allowed;
}

/* 5) Make bot markdown images/links look good everywhere */
#maic-chatbot .maic-message-bot img{
  max-width: 180px;
  height:auto;
  border-radius: 12px;
  border:1px solid var(--maic-border);
  background: var(--maic-surface-2);
}
#maic-chatbot .maic-message-bot a{
  color: var(--maic-link);
  word-break: break-word;
}
#maic-chatbot .maic-message-bot a:hover{
  text-decoration: underline;
}

/* 6) Code blocks */
#maic-chatbot .maic-code{
  background: var(--maic-surface-2);
  color: var(--maic-text);
  border:1px solid var(--maic-border);
  border-radius: 12px;
  padding:10px 12px;
  overflow:auto;
  font-size:12.5px;
  line-height:1.4;
}

/* Motion safety */
@media (prefers-reduced-motion: reduce){
  #maic-chatbot .maic-btn{ transition:none; }
}

/* MAIC: hide toggle when chat is open */
#maic-chatbot.maic-chat-open #maic-chatbot-toggle{
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
  
  /* ========================================================================
     END OF STYLESHEET
     ======================================================================== */

     /* =========================================================
   MAIC - Variation Attributes Selection
   ========================================================= */

/* Variation wrapper (collapsed by default) */
#maic-chatbot .maic-variation {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    transition: max-height 0.28s ease, opacity 0.2s ease, margin-top 0.2s ease, padding-top 0.2s ease, border-top-width 0.2s ease;
}

#maic-chatbot .maic-variation.is-open {
    max-height: 1000px;
    opacity: 1;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--maic-border);
}

/* Variation status message */
#maic-chatbot .maic-variation-status {
    font-size: 12px;
    color: var(--maic-muted);
    margin-bottom: 8px;
    min-height: 18px;
}

#maic-chatbot .maic-variation-status:empty {
    margin-bottom: 0;
    min-height: 0;
    display: none;
}

/* Single attribute group */
#maic-chatbot .maic-attr {
    margin-bottom: 12px;
}

/* Attribute label */
#maic-chatbot .maic-attr-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--maic-text);
    margin-bottom: 6px;
}

/* Attribute values container */
#maic-chatbot .maic-attr-values {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Attribute button */
#maic-chatbot .maic-attr-btn {
    padding: 6px 12px;
    border: 1px solid var(--maic-border);
    border-radius: var(--maic-btn-radius);
    background: transparent;
    color: var(--maic-text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

#maic-chatbot .maic-attr-btn:hover {
    background: color-mix(in srgb, var(--maic-accent) 10%, transparent);
    border-color: color-mix(in srgb, var(--maic-accent) 35%, var(--maic-border));
}

#maic-chatbot .maic-attr-btn.is-active {
    background: var(--maic-accent);
    border-color: var(--maic-accent);
    color: var(--maic-accent-contrast);
    font-weight: 600;
}

#maic-chatbot .maic-attr-btn:active {
    transform: translateY(1px);
}

#maic-chatbot .maic-attr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Focus state for accessibility */
#maic-chatbot .maic-attr-btn:focus-visible {
    outline: 2px solid var(--maic-accent);
    outline-offset: 2px;
}

/* Hidden variation ID field */
#maic-chatbot .maic-variation-id {
    display: none;
}

/* Motion safety */
@media (prefers-reduced-motion: reduce) {
    #maic-chatbot .maic-variation,
    #maic-chatbot .maic-attr-btn {
        transition: none;
    }
}

/* Mobile popup/dock keyboard-safe layout */
@media (max-width: 768px) {
  #maic-chatbot-popup.popup,
  #maic-chatbot-popup.dock {
    position: fixed;
    --maic-side-gap: 8px;
    left: var(--maic-side-gap);
    right: var(--maic-side-gap);
    bottom: calc(var(--maic-side-gap) + var(--maic-kbd, 0px));
    top: auto;
    transform: none;
    width: auto;
    max-width: none;
    margin: 0;
    padding-bottom: 0;
    --maic-top-gap: 16px;
    height: calc(var(--maic-vv-h, 100dvh) - var(--maic-top-gap, 16px));
    max-height: calc(var(--maic-vv-h, 100dvh) - var(--maic-top-gap, 16px));
  }

  #maic-chatbot-popup.popup,
  #maic-chatbot-popup.dock {
    animation: maicMobileFade var(--maic-transition-base) ease;
  }

  #maic-chatbot-popup.popup.is-closing,
  #maic-chatbot-popup.dock.is-closing {
    animation: maicMobileFadeOut var(--maic-transition-base) ease;
    animation-fill-mode: both;
  }

  #maic-chatbot-popup.popup .maic-chatbot-messages,
  #maic-chatbot-popup.dock .maic-chatbot-messages {
    min-height: 0;
    overflow-y: auto;
  }

  #maic-chatbot-popup.popup .maic-chatbot-input-area,
  #maic-chatbot-popup.dock .maic-chatbot-input-area {
    padding-bottom: calc(var(--maic-gap) + env(safe-area-inset-bottom, 0px));
  }
}

@keyframes maicMobileFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes maicMobileFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
