/**
 * HAI UAE — Legacy-to-Modern CSS Bridge
 * Maps legacy CSS variables (--buttonBg, --maxWidth, etc.) to the modern --dir-*
 * token namespace. Also patches critical accessibility/UX gaps in main.css.
 *
 * Loaded AFTER tokens.css, BEFORE main.css.
 * Version: 1.0.0 (2026.09.12)
 */

/* ==========================================================================
   1. Legacy Variable → Modern Token Bridge
   Maps main.css :root vars to the --dir-* system. The legacy variables are
   still consumed by main.css selectors, so we redefine them in terms of
   the canonical tokens.
   ========================================================================== */
:root {
  /* Layout */
  --maxWidth: var(--dir-container-max);
  --mainRadius: var(--dir-radius-md);
  --bigRadius: var(--dir-radius-lg);

  /* Colors — map legacy to modern equivalents */
  --buttonBg: var(--dir-navy);
  --buttonColor: var(--dir-text-white);
  --hColor: var(--dir-navy);
  --textColor: var(--dir-text-main);
  --blueColor: var(--dir-blue);           /* Was #249bb4 (3.04:1 FAIL) → now #1d4ed8 (4.5:1 PASS) */
  --redColor: var(--dir-danger);
  --greenColor: var(--dir-emerald);
  --greenDarkerColor: #065f46;
  --greenVeri: #34d399;
  --greyColor: var(--dir-bg);
  --greyDarkColor: var(--dir-text-main);
  --greyColor2: var(--dir-text-muted);
  --greyLightColor: var(--dir-text-subtle);
  --darkGrey: var(--dir-text-muted);
  --silverColor: var(--dir-border-light);
  --borderColorMain: var(--dir-border-subtle);
  --borderColor: var(--dir-border-subtle);
  --borderColor2: var(--dir-border-subtle);
  --borderColorDark: var(--dir-text-main);
  --butColor: var(--dir-text-main);
}

/* ==========================================================================
   2. Accessibility Fixes — Override Legacy Anti-Patterns
   main.css sets `a:focus { outline: 0 }` which removes ALL focus indicators.
   We restore proper WCAG 2.4.7 keyboard navigation.
   ========================================================================== */

/* Restore focus-visible on ALL interactive elements */
:focus-visible {
  outline: 3px solid var(--dir-blue) !important;
  outline-offset: 3px !important;
  border-radius: var(--dir-radius-sm);
}

/* Only suppress outline for mouse/touch clicks */
:focus:not(:focus-visible) {
  outline: none !important;
}

/* Reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}

/* ==========================================================================
   3. Touch Target Minimums — WCAG 2.5.8 (AA)
   Legacy buttons and links are often under 48×48px. We enforce minimums
   on commonly reused interactive classes.
   ========================================================================== */

/* Legacy pagination links — were ~30×50px, now 48×48px */
.pages_container a,
.pages_container .pages_current,
.pages_container .pages_gap {
  min-height: var(--dir-min-touch-target);
  min-width: var(--dir-min-touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Legacy submit / action buttons */
.submit input[type="submit"],
.submit input[type="button"],
a.submit_link,
a.add_business,
a.blue_button,
a.green_button,
a.more_button,
a.see_all {
  min-height: var(--dir-min-touch-target);
}

/* Mobile hamburger and search buttons */
.m_header_link {
  min-width: var(--dir-min-touch-target);
  min-height: var(--dir-min-touch-target);
}

/* Legacy footer social links */
.social a {
  min-width: var(--dir-min-touch-target);
  min-height: var(--dir-min-touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   4. Typography & Content Readability
   Enforce body line-height, heading line-height, and prose max-width on
   legacy content containers that don't inherit from directory.css.
   ========================================================================== */
body {
  line-height: 1.6;
  font-family: var(--dir-font-sans);
}

#content_container,
#page_text,
#page_text_m,
.art_text,
.desc {
  max-width: var(--dir-prose-max);
  line-height: 1.6;
}

/* Heading hierarchy — enforce line-height 1.1–1.2 on legacy headings */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-family: var(--dir-font-heading);
}

/* ==========================================================================
   5. Image CLS Prevention
   Add aspect-ratio fallback to common image patterns that lack explicit
   dimensions. Only affects containers that use the lazy-bg pattern.
   ========================================================================== */
.art_img {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
  min-height: 180px;
}

/* Ensure all images respect max-width and prevent overflow */
img {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   6. Section Spacing — Fluid Upgrade for Legacy .section Class
   Replaces hardcoded pixel padding with fluid clamp() values on pages
   that load this bridge.
   ========================================================================== */
footer {
  margin-block-start: var(--dir-space-section);
}

/* Override legacy <br/> spacing hacks — they should be margin/padding */
.pages_container {
  margin-block-start: var(--dir-space-lg);
}

/* ==========================================================================
   7. Form Inputs — Focus Ring & Smooth Interactions
   ========================================================================== */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--dir-blue, #1d4ed8) !important;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15) !important;
  outline: none !important;
}

/* ==========================================================================
   8. Subtle Card & Badge Micro-Interactions
   ========================================================================== */
.card-ui,
.ab-card,
.plan-card,
.ads-plan-card,
.ads-stat,
.listing-card {
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.card-ui:hover,
.ab-plan-card:hover,
.listing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--dir-shadow-md, 0 8px 20px -4px rgba(15, 23, 42, 0.08));
}

/* Standardized trust & verified pills */
.badge-verified,
.verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--dir-radius-full, 9999px);
  padding: 0.2rem 0.65rem;
}

/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #1d4ed8, #60a5fa);
  z-index: 99999;
  width: 0%;
  transition: width 100ms ease-out;
}

/* Sticky Mobile Quick-Contact Bar (Company Profile) */
.mobile-contact-bar {
  display: none;
}

@media (max-width: 767.98px) {
  .mobile-contact-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--dir-border-subtle, #e2e8f0);
    padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
    gap: 0.75rem;
    z-index: 1030;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }
  .mobile-contact-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.65rem 0.75rem;
    min-height: 48px;
    border-radius: var(--dir-radius-md, 10px);
    text-decoration: none;
    transition: transform 120ms ease, opacity 120ms ease;
  }
  .mobile-contact-btn:active {
    transform: scale(0.98);
  }
  .mobile-contact-btn--call {
    background: var(--dir-blue, #1d4ed8);
    color: #ffffff !important;
  }
  .mobile-contact-btn--whatsapp {
    background: #25d366;
    color: #064e3b !important;
  }
  .mobile-contact-btn--review {
    background: var(--dir-bg, #f8fafc);
    border: 1px solid var(--dir-border-subtle, #e2e8f0);
    color: var(--dir-text-main, #0f172a) !important;
  }
}

/* ==========================================================================
   Footer Trust & Security Strip
   ========================================================================== */
.hf-trust-strip {
  background: #0f172a;
  border-top: 1px solid #1e293b;
  border-bottom: 1px solid #1e293b;
  padding: 13px 0;
}

.hf-trust-strip-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px 16px;
}

.hf-trust-badge-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #94a3b8;
  font-size: 12px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease;
}

.hf-trust-badge-item:hover,
.hf-trust-badge-item:focus {
  color: #38bdf8;
  text-decoration: none;
  transform: translateY(-1px);
}

.hf-trust-badge-item:hover strong,
.hf-trust-badge-item:focus strong {
  color: #ffffff;
}

.hf-trust-badge-item i {
  font-size: 13px;
  transition: transform 0.18s ease;
}

.hf-trust-badge-item:hover i,
.hf-trust-badge-item:focus i {
  transform: scale(1.15);
}

.hf-trust-badge-item strong {
  color: #f8fafc;
  font-weight: 700;
  transition: color 0.18s ease;
}

@media (max-width: 991px) {
  .hf-trust-strip-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 18px;
  }
  .hf-trust-badge-item {
    font-size: 11.5px;
  }
}

@media (max-width: 576px) {
  .hf-trust-strip-inner {
    gap: 8px 12px;
  }
  .hf-trust-badge-item {
    font-size: 11px;
  }
}

/* ==========================================================================
   Verified Embed Badge Modal & Trigger
   ========================================================================== */
.embed-badge-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.embed-badge-trigger-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.hai-badge-modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.hai-badge-modal {
  background: #ffffff;
  border-radius: 14px;
  max-width: 540px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  position: relative;
  box-sizing: border-box;
}

.hai-badge-modal h3 {
  margin: 0 0 6px 0;
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.hai-badge-modal p {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
}

.badge-preview-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.badge-tab-btn {
  flex: 1;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  border-radius: 6px;
  cursor: pointer;
}

.badge-tab-btn.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.badge-display-box {
  background: #f1f5f9;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 14px;
  border: 1px dashed #cbd5e1;
}

.badge-snippet-textarea {
  width: 100%;
  height: 70px;
  font-family: monospace;
  font-size: 11.5px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  box-sizing: border-box;
  resize: none;
}

.badge-copy-btn {
  width: 100%;
  padding: 10px;
  background: #ffcb05;
  color: #0f172a;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.15s;
}

.badge-copy-btn:hover {
  background: #e5b600;
}

.badge-modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
}

