/* ===== AI Chat Drawer & Floating Button (Phase 81) ===== */

:root {
  --ai-drawer-w: 440px;
  --ai-z:        9000;
  --ai-float-z:  8000;
}

/* ── Overlay backdrop ──────────────────────────────────── */
.ai-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: var(--ai-z);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.ai-chat-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Drawer ────────────────────────────────────────────── */
.ai-chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--ai-drawer-w);
  height: 100dvh;
  background: #fff;
  display: flex;
  flex-direction: column;
  z-index: calc(var(--ai-z) + 1);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(.25, .46, .45, .94);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  border-left: 1px solid #eaeaea;
}
.ai-chat-overlay.is-open .ai-chat-drawer {
  transform: translateX(0);
}

/* ── Drawer header ─────────────────────────────────────── */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eaeaea;
  flex-shrink: 0;
  background: #fff;
}
.ai-chat-title {
  font-size: 14px;
  font-weight: 700;
  color: #111;
  letter-spacing: -0.01em;
}
.ai-chat-close {
  background: none;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: #555;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
.ai-chat-close:hover  { background: #f6f6f6; border-color: #bbb; }
.ai-chat-close:active { background: #efefef; }

/* ── iframe ────────────────────────────────────────────── */
.ai-chat-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: none;
}

/* ── Floating button (mobile primary CTA) ──────────────── */
.ai-chat-float {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: var(--ai-float-z);
  background: #111;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  display: none; /* shown via auth check + @media */
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ai-chat-float:hover  { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.ai-chat-float:active { transform: translateY(0);    box-shadow: 0 2px 8px  rgba(0,0,0,.2); }

/* ── Mobile overrides (≤ 640px) ────────────────────────── */
@media (max-width: 640px) {
  /* Floating button is primary on mobile */
  .ai-chat-float { display: flex; }

  /* navBar AI button hidden on mobile (floating takes over) */
  #btnNavAiChat { display: none !important; }

  /* Full-screen drawer */
  .ai-chat-drawer {
    width: 100%;
    border-left: none;
    box-shadow: none;
  }
}

/* ── orders.html: expand mainActions grid when AI button present ── */
@media (max-width: 900px) {
  .mainActions:has(#btnNavAiChat) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
