/* ==========================================================================
   NexusAI / Apple iOS 18 Legal & Rules Stylesheet (legal.css)
   Strictly aligned with ui_skils design guidelines & PRD 2.2
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg-canvas: #000000;
  --bg-surface: #0a0a0c;
  --card-bg: rgba(14, 14, 18, 0.72);
  --card-bg-hover: rgba(22, 22, 28, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --accent-emerald: #10b981;
  --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --text-primary: #f5f5f7;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;
  --glass-highlight: inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
  --shadow-card: 0 20px 50px -12px rgba(0, 0, 0, 0.9);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-canvas);
  color: var(--text-secondary);
  font-family: 'Vazirmatn', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, Tahoma, sans-serif;
  line-height: 1.8;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

a, button {
  touch-action: manipulation;
}

a:active, button:active {
  transform: scale(0.97) translateY(1px);
  transition: transform 0.08s ease;
}

.is-navigating {
  pointer-events: none !important;
  opacity: 0.7 !important;
  cursor: wait !important;
}

.shell {
  width: min(960px, calc(100% - 36px));
  margin-inline: auto;
}

/* Ambient Diffused Glow Orbs */
.legal-glow {
  position: fixed;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(120px);
}

.glow-top {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.14) 0%, rgba(99, 102, 241, 0.08) 60%, transparent 80%);
  top: -200px;
  right: -100px;
}

.glow-bottom {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.1) 0%, rgba(139, 92, 246, 0.08) 60%, transparent 80%);
  bottom: -200px;
  left: -100px;
}

/* Floating Pill Header */
.legal-header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  margin-bottom: 24px;
  padding: 6px 20px;
  border-radius: 9999px;
  background: rgba(10, 10, 14, 0.75);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8), var(--glass-highlight);
}

.legal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  direction: ltr;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  padding: 6px;
  background: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.legal-brand b {
  font-family: 'Outfit', sans-serif;
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
}

.legal-brand em {
  color: var(--accent-emerald);
  font-style: normal;
}

.legal-brand small {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  direction: rtl;
  text-align: left;
}

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

/* Pill Buttons */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.pill-btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.pill-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.pill-btn.primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35), var(--glass-highlight);
}

.pill-btn.primary:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

/* Legal Container & Tabs */
.legal-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 60px;
}

.legal-tabs-bar {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 5px;
  align-self: flex-start;
}

.legal-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 9999px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.legal-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.legal-tab.active {
  background: #0084FF;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 132, 255, 0.38);
}

/* Legal Main Card */
.legal-card {
  border-radius: 28px;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-card), var(--glass-highlight);
  padding: 42px 46px;
}

.legal-card-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 32px;
}

.legal-icon {
  width: 56px;
  height: 56px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 26px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.icon-emerald {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.icon-cyan {
  background: rgba(6, 182, 212, 0.12);
  color: #38bdf8;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.2);
}

.legal-card-header h1 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 900;
  color: #ffffff;
  margin: 0 0 6px;
  line-height: 1.3;
}

.meta-date {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.legal-section {
  margin-bottom: 36px;
}

.legal-section h2 {
  font-size: 17px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.legal-section p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 2;
  margin: 0 0 14px;
}

.legal-checklist {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legal-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.8;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 12px 16px;
  border-radius: 16px;
}

.text-emerald { color: #10b981; }
.text-rose { color: #f43f5e; }

.legal-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.legal-footer {
  text-align: center;
  padding: 30px 0;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .legal-header {
    height: auto;
    border-radius: 24px;
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  .legal-tabs-bar {
    width: 100%;
    flex-direction: column;
    border-radius: 20px;
  }
  .legal-tab {
    justify-content: center;
  }
  .legal-card {
    padding: 24px 20px;
    border-radius: 24px;
  }
  .legal-card-header {
    flex-direction: column;
    text-align: center;
  }
  .legal-card-footer {
    flex-direction: column;
  }
  .legal-card-footer .pill-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Shared phone safeguards. This file is appended to every page stylesheet. */
@media (max-width: 700px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  html, body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  img, picture, video, canvas, svg {
    max-width: 100%;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px !important; /* prevents Safari's focus-zoom */
  }

  button, a, input, select, textarea {
    touch-action: manipulation;
  }

  pre, code {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .overflow-x-auto, .overflow-x-scroll, [class*="overflow-x-auto"], [class*="overflow-x-scroll"] {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  #modal-overlay > *, [role="dialog"] {
    max-width: calc(100vw - 2rem);
    max-height: calc(100dvh - 2rem);
  }
}

/* ==========================================================================
   Package B: Apple HIG & Mobile UX Refinement (PRD 1.2 / MOBILE_UX_SKILL)
   ========================================================================== */

/* 1. Touch-First Target Size & Thumb Zone Layout */
button, a, .chip, input, select, [role="button"] {
  min-height: 44px;
}

/* 2. Horizontal Snap Chips for Categories & Filters */
.mobile-chip-bar,
.category-chips,
.am-categories-grid,
.am-category-chips,
.industry-category-list,
.nexus-category-list {
  display: flex !important;
  gap: 8px !important;
  overflow-x: auto !important;
  scroll-snap-type: x mandatory !important;
  -webkit-overflow-scrolling: touch !important;
  padding: 8px 12px !important;
  scrollbar-width: none !important;
}
.mobile-chip-bar::-webkit-scrollbar,
.category-chips::-webkit-scrollbar,
.am-categories-grid::-webkit-scrollbar,
.am-category-chips::-webkit-scrollbar,
.industry-category-list::-webkit-scrollbar,
.nexus-category-list::-webkit-scrollbar {
  display: none !important;
}
.mobile-chip-bar .chip,
.mobile-chip-bar > *,
.category-chips > *,
.industry-category,
.nexus-category,
.am-category-chip,
.am-category-item {
  scroll-snap-align: start !important;
  flex-shrink: 0 !important;
  padding: 8px 16px !important;
  border-radius: 9999px !important;
  font-size: 14px !important;
  white-space: nowrap !important;
}

/* 3. Mobile Product Grid & Uniform Aspect Ratios (< 640px) */
@media (max-width: 639.98px) {
  .product-grid,
  .catalog-grid,
  .am-products-grid,
  .industry-product-grid,
  .industry-catalog-grid,
  .nexus-product-grid,
  .nexus-catalog-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    padding: 10px !important;
  }

  .product-card,
  .catalog-card,
  .am-product-card,
  .industry-product-card,
  .industry-catalog-card,
  .nexus-product-card,
  .nexus-catalog-card {
    display: flex !important;
    flex-direction: column !important;
    border-radius: 16px !important;
    overflow: hidden !important;
  }

  .product-card img,
  .catalog-image img,
  .am-product-img-container img,
  .am-product-card img,
  .industry-product-image img,
  .industry-catalog-image img,
  .nexus-product-image img,
  .nexus-catalog-image img {
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
  }

  .product-card .title,
  .catalog-copy h3,
  .catalog-card h3,
  .am-product-title,
  .industry-product-copy h3,
  .industry-catalog-copy h2,
  .nexus-product-copy h3,
  .nexus-catalog-copy h2 {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    min-height: 36px !important;
  }
}

/* 4. Floating Action Buttons (FAB) Collision Fix */
@media (max-width: 639.98px) {
  .whatsapp-floating-btn,
  .whatsapp-fab,
  .support-fab,
  .direct-support-fab,
  #whatsapp-floating-btn,
  [data-fab="whatsapp"],
  .floating-contact,
  .am-fab-whatsapp {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 998 !important;
  }

  .ai-assistant-widget,
  .ai-floating-btn,
  .ai-fab,
  #ai-assistant-bubble,
  #ai-chat-fab,
  [data-fab="ai"],
  .floating-ai-btn,
  .am-fab-ai {
    position: fixed !important;
    bottom: 85px !important;
    right: 20px !important;
    z-index: 997 !important;
  }
}

/* 5. Sticky Bottom Purchase Bar (Product Details View) */
.sticky-buy-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(18, 18, 24, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 990;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

@media (min-width: 641px) {
  .sticky-buy-bar.mobile-only {
    display: none !important;
  }
}

/* 6. Bottom Sheet Drawer (Cart & Checkout Modal on Screens < 640px) */
@media (max-width: 640px) {
  .modal-dialog,
  .checkout-modal,
  .cart-drawer,
  .bottom-sheet,
  .modal-sheet,
  .industry-modal-card,
  .nexus-modal-card {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 24px 24px 0 0 !important;
    transform: translateY(0) !important;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
