/* =========================================================
   AI Support Widget — Arklab
   ========================================================= */

#aisupport-widget * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.ais-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999998;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== BULLE ===== */
.ais-bubble {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      background: #0f172a;
      box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25), 0 4px 10px rgba(15, 23, 42, 0.1);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
      position: relative;
      border: 2px solid var(--ais-primary, #FF6F96);
  }
  .ais-bubble:hover {
      transform: translateY(-2px);
      box-shadow: 0 14px 36px rgba(15, 23, 42, 0.3), 0 6px 14px rgba(15, 23, 42, 0.12);
  }
  .ais-bubble:active { transform: translateY(0) scale(0.97); }
  .ais-bubble svg {
      width: 30px;
      height: 30px;
      color: var(--ais-primary, #FF6F96);
  }
  .ais-bubble.ais-pulse::before {
      content: '';
      position: absolute;
      inset: -2px;
      border-radius: 50%;
      border: 2px solid var(--ais-primary, #FF6F96);
      opacity: 0.6;
      animation: ais-pulse 2s ease-out infinite;
      z-index: -1;
  }

/* Tooltip d'invitation */
.ais-tooltip {
    position: absolute;
    right: 76px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    color: #0f172a;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.ais-tooltip.visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}
.ais-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: white;
}

/* ===== PANNEAU CHAT ===== */
.ais-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 640px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2), 0 2px 8px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    animation: ais-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.ais-panel.open { display: flex; }
@keyframes ais-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Mobile : plein écran */
@media (max-width: 500px) {
    .ais-panel {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .ais-root { bottom: 16px; right: 16px; }
    .ais-bubble { width: 56px; height: 56px; }
    .ais-bubble svg { width: 24px; height: 24px; }
}

/* ===== HEADER ===== */
.ais-header {
      background: #0f172a;
      color: white;
      padding: 18px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-shrink: 0;
      position: relative;
  }
  .ais-header::after {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      height: 2px;
      background: var(--ais-primary, #FF6F96);
  }
.ais-header-info { display: flex; align-items: center; gap: 12px; }
.ais-header-avatar {
      width: 42px;
      height: 42px;
      border-radius: 50%;
      background: var(--ais-primary, #FF6F96);
      display: flex;
      align-items: center;
      justify-content: center;
      color: #0f172a;
      flex-shrink: 0;
  }
  .ais-header-avatar svg {
      width: 22px;
      height: 22px;
  }
.ais-header-text { display: flex; flex-direction: column; }
.ais-header-title { font-size: 15px; font-weight: 800; letter-spacing: -0.3px; }
.ais-header-subtitle-name {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.7;
    margin-top: 1px;
  }
.ais-header-subtitle {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ais-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}
.ais-btn-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ais-btn-close:hover { background: rgba(255, 255, 255, 0.25); }
.ais-btn-close svg { width: 16px; height: 16px; }

/* ===== BANDEAU RGPD ===== */
.ais-rgpd-banner {
    background: #fff8e1;
    border-bottom: 1px solid #ffe082;
    padding: 14px 18px;
    font-size: 12px;
    color: #7a5900;
    line-height: 1.5;
    flex-shrink: 0;
}
.ais-rgpd-banner a {
    color: #5d4400;
    text-decoration: underline;
    font-weight: 600;
}
.ais-rgpd-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.ais-rgpd-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: opacity 0.2s;
}
.ais-rgpd-btn-accept {
    background: #0f172a;
    color: white;
}
.ais-rgpd-btn-decline {
    background: white;
    color: #64748b;
    border: 1px solid #cbd5e1;
}
.ais-rgpd-btn:hover { opacity: 0.85; }

/* ===== MESSAGES ===== */
.ais-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fc;
    -webkit-overflow-scrolling: touch;
}
.ais-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: ais-msg-in 0.2s ease;
}
@keyframes ais-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ais-msg-assistant {
    align-self: flex-start;
    background: white;
    color: #0f172a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    border: 1px solid #eef2f6;
}
.ais-msg-user {
    align-self: flex-end;
    background: #0f172a;
    color: white;
    border-bottom-right-radius: 4px;
}
.ais-msg-system {
    align-self: center;
    background: #fef3c7;
    color: #78350f;
    border: 1px solid #fde68a;
    font-size: 12px;
    max-width: 92%;
    text-align: center;
}

/* Indicateur "en train d'écrire" */
.ais-typing {
    align-self: flex-start;
    background: white;
    padding: 14px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    border: 1px solid #eef2f6;
    display: flex;
    gap: 4px;
}
.ais-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: ais-bounce 1.4s infinite ease-in-out both;
}
.ais-typing span:nth-child(1) { animation-delay: -0.32s; }
.ais-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ais-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== SUGGESTIONS ===== */
.ais-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
    background: #f8f9fc;
}
.ais-suggestion {
    background: white;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    padding: 8px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.ais-suggestion:hover {
    border-color: var(--ais-primary, #FF6F96);
    color: var(--ais-primary, #FF6F96);
    background: #fff5f8;
}

/* ===== INPUT ===== */
.ais-input-wrapper {
    padding: 14px 16px;
    background: white;
    border-top: 1px solid #eef2f6;
    flex-shrink: 0;
    position: relative;
}
.ais-input-box {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #f8f9fc;
    border-radius: 16px;
    padding: 8px 8px 8px 14px;
    border: 1px solid #e2e8f0;
    transition: border-color 0.2s;
}
.ais-input-box:focus-within {
    border-color: #0f172a;
    background: white;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}
.ais-input {
      flex: 1;
      border: none;
      background: transparent;
      resize: none;
      outline: none;
      font-family: inherit;
      font-size: 14px;
      line-height: 1.4;
      max-height: 120px;
      min-height: 22px;
      padding: 6px 0;
      color: #0f172a;
  }
  /* Empêche le zoom iOS au focus (font-size >= 16px obligatoire sur mobile) */
  @media (max-width: 500px) {
      .ais-input {
          font-size: 16px;
      }
  }
.ais-input::placeholder { color: #94a3b8; }
.ais-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #0f172a;
    color: var(--ais-primary, #FF6F96);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.ais-send-btn:hover { transform: scale(1.05); }
.ais-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}
.ais-send-btn svg { width: 16px; height: 16px; }

.ais-end-conv-btn {
    display: none;
    background: white;
    border: 1px solid #e9d5d5;
    color: #c4a0a0;
    padding: 5px 16px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.07);
}
.ais-end-conv-btn:hover {
    border-color: #fca5a5;
    color: #dc2626;
    box-shadow: 0 2px 10px rgba(220, 38, 38, 0.12);
    transform: translateY(-1px);
}
.ais-end-conv-btn:active {
    transform: translateY(0);
}

.ais-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 10px;
    color: #94a3b8;
    font-weight: 500;
}
.ais-input-footer a {
    color: #94a3b8;
    text-decoration: underline;
}

/* ===== Header actions (menu + close) ===== */
.ais-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}
.ais-btn-menu {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ais-btn-menu:hover { background: rgba(255, 255, 255, 0.25); }
.ais-btn-menu svg { width: 18px; height: 18px; }

.ais-menu-dropdown {
    position: absolute;
    top: 48px;
    right: 42px;
    min-width: 220px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(15, 23, 42, 0.06);
    padding: 6px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.15s, transform 0.15s;
    z-index: 10;
}
.ais-menu-dropdown.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.ais-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #0f172a;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.ais-menu-item:hover {
    background: #f1f5f9;
    color: var(--ais-primary, #FF6F96);
}
.ais-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: currentColor;
}

/* ===== Confirm dialog (widget) ===== */
.ais-confirm-widget-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ais-confirm-fade 0.15s ease;
}
@keyframes ais-confirm-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
.ais-confirm-widget-box {
    width: 100%;
    max-width: 380px;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: ais-confirm-scale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
}
@keyframes ais-confirm-scale {
    from { transform: scale(0.94); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.ais-confirm-widget-title {
    font-size: 17px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}
.ais-confirm-widget-text {
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 20px;
}
.ais-confirm-widget-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.ais-confirm-widget-btn {
    padding: 10px 18px;
    border-radius: 100px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background: white;
    color: #0f172a;
    transition: all 0.15s;
}
.ais-confirm-widget-btn:hover {
    background: #f1f5f9;
}
.ais-confirm-widget-btn.primary {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}
.ais-confirm-widget-btn.primary:hover {
    opacity: 0.9;
}

/* Mobile : ajuste position dropdown */
@media (max-width: 500px) {
    .ais-menu-dropdown {
        right: 12px;
        top: 52px;
        min-width: 200px;
    }
}

/* =========================================================
   Bloc "Demande SAV" — offre déclenchée par le modèle
   ========================================================= */
.ais-sav-offer {
    align-self: stretch;
    margin: 10px 0;
    padding: 14px 16px;
    border-radius: 14px;
    background: linear-gradient(180deg, #fff5f8 0%, #fff 100%);
    border: 1.5px solid var(--ais-primary, #FF6F96);
    box-shadow: 0 6px 18px rgba(255, 111, 150, 0.15);
    animation: ais-sav-slide-in 0.28s ease-out;
}
@keyframes ais-sav-slide-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ais-sav-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    color: #9f1239;
    margin-bottom: 10px;
}
.ais-sav-icon { font-size: 16px; line-height: 1; }

.ais-sav-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.ais-sav-form-logged {
    background: #fff;
    border: 1px dashed #ffd6e2;
    border-radius: 10px;
    padding: 10px 12px;
}
.ais-sav-logged-info {
    font-size: 13px;
    color: #475569;
    line-height: 1.5;
}
.ais-sav-logged-info strong { color: #0f172a; }

.ais-sav-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-top: 4px;
}
.ais-sav-input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #fff;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}
.ais-sav-input:focus {
    border-color: var(--ais-primary, #FF6F96);
    box-shadow: 0 0 0 3px rgba(255, 111, 150, 0.18);
}
.ais-sav-input.invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.ais-sav-error {
    font-size: 12px;
    color: #b91c1c;
    background: #fee2e2;
    border-radius: 8px;
    padding: 6px 10px;
    line-height: 1.35;
    margin-top: 4px;
}

.ais-sav-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.ais-sav-btn {
    border: none;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.ais-sav-btn:active { transform: translateY(1px); }
.ais-sav-btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}
.ais-sav-btn-cancel {
    background: #f1f5f9;
    color: #475569;
}
.ais-sav-btn-cancel:hover:not([disabled]) { background: #e2e8f0; }
.ais-sav-btn-submit {
    background: var(--ais-primary, #FF6F96);
    color: #fff;
    box-shadow: 0 3px 10px rgba(255, 111, 150, 0.35);
}
.ais-sav-btn-submit:hover:not([disabled]) { opacity: 0.92; }

/* État après envoi réussi — remplace le bloc formulaire */
.ais-sav-success {
    align-self: stretch;
    margin: 10px 0;
    padding: 18px 16px;
    text-align: center;
    border-radius: 14px;
    background: linear-gradient(180deg, #ecfdf5 0%, #fff 100%);
    border: 1.5px solid #10b981;
    animation: ais-sav-slide-in 0.28s ease-out;
}
.ais-sav-success-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: #10b981;
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    line-height: 44px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}
.ais-sav-success-title {
    font-weight: 800;
    font-size: 15px;
    color: #065f46;
    margin-bottom: 4px;
}
.ais-sav-success-text {
    font-size: 13px;
    color: #047857;
    line-height: 1.5;
}

/* =========================================================
   Cartes produits — rendues après tool search_products
   ========================================================= */
.ais-products {
    align-self: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 10px;
    animation: ais-sav-slide-in 0.28s ease-out;
}
.ais-product-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.ais-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    border-color: var(--ais-primary, #FF6F96);
}
.ais-product-img {
    aspect-ratio: 1 / 1;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ais-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ais-product-img-empty {
    background:
        repeating-linear-gradient(135deg, #f1f5f9 0 8px, #e2e8f0 8px 16px);
}
.ais-product-body {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.ais-product-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
    color: #0f172a;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ais-product-short {
    font-size: 11.5px;
    line-height: 1.35;
    color: #64748b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ais-product-foot {
    margin-top: auto;
    padding-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.ais-product-price {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--ais-primary, #FF6F96);
}
.ais-product-oos {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #b91c1c;
    background: #fee2e2;
    padding: 2px 6px;
    border-radius: 999px;
}

@media (max-width: 420px) {
    .ais-products {
        grid-template-columns: 1fr;
    }
}