/**
 * App-specific CSS (non-Tailwind utilities).
 * Loaded after app.css. Template / JS dynamic values use CSS variables, e.g. style="--w: 45%".
 */

/* ── Tool pages: results stack below hero (form lives in hero split) ─── */
.tool-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Remove duplicate top margin on first result card (templates often use mt-5) */
.tool-results-column > :first-child {
  margin-top: 0 !important;
}

/* Collapsible SEO / guide block on tool pages */
details.tool-seo-details > summary {
  list-style: none;
}
details.tool-seo-details > summary::-webkit-details-marker {
  display: none;
}

details.tool-seo-details[open] .tool-seo-chevron {
  transform: rotate(180deg);
}

/* Primary result card inside tool hero (left column) — grow with content, no inner scroll */
.tool-result-hero-shell {
  min-width: 0;
  overflow: visible;
}

/* Prevent long unbroken output (minified/SVG/hash) from stretching page width */
.tool-result-hero-shell,
[data-tool-result-panel] {
  min-width: 0;
  max-width: 100%;
}

.tool-result-hero-shell *,
[data-tool-result-panel] * {
  min-width: 0;
  max-width: 100%;
}

.tool-result-hero-shell pre,
.tool-result-hero-shell code,
.tool-result-hero-shell textarea,
[data-tool-result-panel] pre,
[data-tool-result-panel] code,
[data-tool-result-panel] textarea {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Tool hero: grid row equal height + header band */
.tool-hero-columns {
  min-height: 0;
}
.tool-hero-header {
  width: 100%;
}
.tool-hero-divider {
  flex-shrink: 0;
}

/*
 * Right column: single root in {% block tool_right_column %} (default card or custom UI).
 * Natural height — no inner scroll; page scrolls as a whole.
 */
.tool-hero-form-slot {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

.tool-hero-form-slot > * {
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

/* Searchable meta combobox (currency / country / city) */
.meta-combobox-dropdown {
  box-shadow: 0 10px 40px -10px rgba(15, 23, 42, 0.25);
}
.meta-combobox-option {
  scroll-margin: 2px;
}

/* Mobile header search: one pill; input must shrink so button stays inside */
.header-mobile-search-form {
  box-sizing: border-box;
  max-width: 100%;
  width: 100%;
}
.header-mobile-search-form input[type="search"] {
  min-width: 0;
  flex: 1 1 0%;
  -webkit-appearance: none;
  appearance: none;
}

/* ── Header / nav ─────────────────────────────────────────────────────── */
.tools-mega-menu {
  width: min(1100px, 96vw);
  max-height: 82vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.cat-strip-scroll {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cat-strip-scroll::-webkit-scrollbar {
  display: none;
}

/* Category-strip panel that mirrors the Tools mega menu (width, height, no inner padding) */
.cat-dropdown.cat-dropdown-panel.tools-mega-menu {
  z-index: 10050;
  min-width: min(1100px, 96vw);
  width: min(1100px, 96vw);
  max-width: calc(100vw - 16px);
  max-height: 82vh;
  padding: 0;
}

/* Narrow SEO strip dropdown: width follows content (single column), not full mega width */
.cat-dropdown.cat-dropdown-panel.tools-mega-menu.mega-menu-width-auto {
  width: fit-content;
  min-width: min(16rem, calc(100vw - 16px));
  max-width: min(28rem, calc(100vw - 16px));
}

.cat-dropdown.cat-dropdown-panel {
  position: fixed;
  z-index: 9999;
  min-width: 230px;
  max-width: min(100vw - 16px, 320px);
  max-height: min(70vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 0.5rem;
  box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.18);
}

.mobile-mega-scroll-touch {
  -webkit-overflow-scrolling: touch;
}

/* ── Search (hero suggestions anchor) ────────────────────────────────── */
.hero-suggestions-top {
  top: calc(100% + 0.5rem);
}

/* ── Loan calculator split bar ──────────────────────────────────────────── */
.loan-bar-principal {
  width: var(--w);
  background: linear-gradient(90deg, #4338ca 0%, #4f46e5 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.loan-bar-interest {
  width: var(--w);
  background: linear-gradient(90deg, #be123c 0%, #e11d48 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ── Discount calculator bar ───────────────────────────────────────────── */
.discount-bar-seg {
  width: var(--w);
}

/* ── BMI scale ─────────────────────────────────────────────────────────── */
.bmi-scale-track {
  background: linear-gradient(
    to right,
    #38bdf8 0%,
    #38bdf8 46%,
    #34d399 46%,
    #34d399 62.5%,
    #fbbf24 62.5%,
    #fbbf24 75%,
    #fb923c 75%,
    #fb923c 87.5%,
    #f87171 87.5%,
    #ef4444 100%
  );
}
.bmi-scale-marker {
  left: var(--left);
}

/* ── Generic width from server (progress bars) ───────────────────────────── */
.w-pct {
  width: var(--w);
}

/* ── Zakat dynamic row colour dot ──────────────────────────────────────── */
.zakat-colour-dot {
  background: var(--c);
}

/* ── Unit converter tabs ───────────────────────────────────────────────── */
.uc-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  border-radius: 0.625rem;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.uc-tab:hover {
  border-color: #7dd3fc;
  background: #f0f9ff;
  color: #0369a1;
}
.uc-tab.active {
  border-color: #0ea5e9;
  background: #e0f2fe;
  color: #0369a1;
}

/* ── Zakat calculator form hints ───────────────────────────────────────── */
[dir="rtl"],
.zakat-label span {
  font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
}
.zakat-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
  line-height: 1.5;
}
.zakat-input {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.zakat-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.zakat-hint {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: #94a3b8;
  line-height: 1.5;
}
details[open] .section-arrow {
  transform: rotate(180deg);
}

/* ── Qibla finder ──────────────────────────────────────────────────────── */
.qibla-hero-dots {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.4) 1px, transparent 1px);
  background-size: 20px 20px;
}

#qibla-needle {
  transform-origin: 110px 110px;
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

#room-arrow {
  transform-origin: 100px 110px;
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.qibla-map-host {
  height: 360px;
  z-index: 1;
}

.qibla-leaflet-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid white;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.qibla-leaflet-marker--user {
  width: 32px;
  height: 32px;
  background: #4f46e5;
  border-radius: 50%;
  font-size: 14px;
}
.qibla-leaflet-marker--kaaba {
  width: 36px;
  height: 36px;
  background: #16a34a;
  border-radius: 8px;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ── Setup wizard (scoped) ───────────────────────────────────────────── */
.setup-wizard-page,
.setup-wizard-page * {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.setup-wizard-page {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #0f172a 100%);
  background-attachment: fixed;
}

.setup-wizard-page .step-line {
  flex: 1;
  height: 2px;
  background: #e2e8f0;
  margin: 0 8px;
  transition: background 0.4s;
}
.setup-wizard-page .step-line.done {
  background: #6366f1;
}

.setup-wizard-page .field-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.setup-wizard-page .field-input {
  transition: border-color 0.2s, box-shadow 0.2s;
}
.setup-wizard-page .field-input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.setup-wizard-page .field-input.success {
  border-color: #10b981;
}

.setup-wizard-page .pw-bar {
  height: 4px;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}

.setup-wizard-page .install-step {
  transition: opacity 0.3s, transform 0.3s;
}
.setup-wizard-page .install-step.pending {
  opacity: 0.35;
}
.setup-wizard-page .install-step.running,
.setup-wizard-page .install-step.done-ok,
.setup-wizard-page .install-step.done-err {
  opacity: 1;
}

@keyframes setup-confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}
.setup-wizard-page .confetti,
.confetti {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: setup-confetti-fall linear forwards;
  pointer-events: none;
}

@keyframes setup-spin {
  to {
    transform: rotate(360deg);
  }
}
.setup-wizard-page .spin,
.spin {
  animation: setup-spin 0.8s linear infinite;
}

@keyframes setup-pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}
.setup-wizard-page .pulse-dot {
  animation: setup-pulse-dot 1.2s ease-in-out infinite;
}

.setup-install-overlay {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
}

.setup-success-screen {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
}

/* ── Tool pages: print / save as PDF (browser dialog) ─────────────────── */
@media print {
  header,
  footer,
  #back-to-top,
  .no-print,
  .tool-xp-toolbar,
  .tool-seo-details,
  nav[aria-label="Breadcrumb"] {
    display: none !important;
  }
  body {
    background: #fff !important;
  }
  #main-content {
    padding: 0.5rem !important;
    max-width: 100% !important;
  }
  .tool-print-area {
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
    background: #fff !important;
    color: #0f172a !important;
    break-inside: avoid;
  }
}

/* Step-by-step detail blocks (toggled by tool_experience.js) */
.tool-result-detail {
  border-radius: 0.75rem;
  border: 1px solid rgb(226 232 240);
  background: rgb(248 250 252);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: rgb(51 65 85);
}
.tool-result-detail h3 {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(71 85 105);
  margin-bottom: 0.5rem;
}
