/* QuickUtil Mobile UX — mobile-only rules inside media queries. Desktop-scoped fixes (dark mode, search bar) are at the bottom. */

/* ============================================================
   CHANGE 1 — Compact hero on mobile
   ============================================================ */
@media (max-width: 768px) {
  .page-hero {
    padding: 16px 0 !important;
  }
  .page-hero h1 {
    font-size: 26px !important;
    margin-bottom: 6px !important;
  }
  /* Clamp subtitle to 1 line */
  .page-hero p,
  .page-hero .hero-desc {
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    font-size: 14px !important;
    margin: 0 auto !important;
  }
  /* Hide breadcrumbs on mobile */
  .breadcrumb,
  .hero-breadcrumb {
    display: none !important;
  }
  /* Compact category icon */
  .cat-hero-icon {
    width: 44px !important;
    height: 44px !important;
    margin-bottom: 10px !important;
  }
}

/* ============================================================
   CHANGE 2 — iOS-style inputs on mobile
   ============================================================ */
@media (max-width: 768px) {
  .form-input,
  .form-select,
  input[type="number"],
  input[type="text"],
  input[type="date"],
  select {
    height: 52px !important;
    border-radius: 14px !important;
    font-size: 17px !important;
    padding: 0 16px !important;
    border: 1.5px solid var(--border) !important;
    background: var(--color-input-bg) !important;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Keep select arrow visible */
  .form-select,
  select {
    padding-right: 40px !important;
  }

  .form-group {
    margin-bottom: 12px !important;
  }

  .form-label,
  label {
    font-size: 13px !important;
    font-weight: 500 !important;
    margin-bottom: 4px !important;
    color: var(--slate) !important;
  }

  /* Full-width prominent calculate button */
  button[type="submit"],
  .btn.btn-primary {
    height: 54px !important;
    border-radius: 14px !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    width: 100% !important;
    margin-top: 8px !important;
  }

  /* Hide "fill in the form" placeholder on mobile — useless in app flow */
  #calcPlaceholder,
  .calc-placeholder {
    display: none !important;
  }
}

/* ============================================================
   CHANGE 3 — Mobile results replace the form (app-like transition)
   ============================================================ */
@media (max-width: 768px) {
  .calc-wrapper {
    position: relative;
    min-height: 60vh;
  }

  /* Inputs panel — collapse on results-visible */
  .calc-inputs {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
  }

  .results-visible .calc-inputs {
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Recalculate button — injected by JS, only shown when results are visible */
  .mobile-recalculate-btn {
    display: none;
  }

  .results-visible .mobile-recalculate-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 16px;
  }
}

@media (min-width: 769px) {
  .mobile-recalculate-btn {
    display: none !important;
  }
}

/* ============================================================
   CHANGE 4 — Category pages: 2-column compact tool grid
   ============================================================ */
@media (max-width: 768px) {
  .tools-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  .tool-card {
    height: auto !important;
    min-height: 140px !important;
    padding: 14px !important;
    border-radius: 16px !important;
  }

  .tool-card-name {
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    margin-bottom: 4px !important;
    padding-right: 0 !important;
  }

  .tool-card-desc {
    display: none !important;
  }

  .tool-card-cta {
    font-size: 11px !important;
    padding: 0 !important;
    margin-top: auto !important;
  }

  .badge-soon {
    font-size: 9px !important;
    padding: 2px 6px !important;
    top: 8px !important;
    right: 8px !important;
  }
}

/* ============================================================
   CHANGE 5 — Related Tools: horizontal stacked cards on mobile
   ============================================================ */
@media (max-width: 768px) {
  /* 1-column stack */
  .related-tools-section > .container > div {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Horizontal card: icon left, text right */
  .related-tools-section .card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 14px 16px !important;
    height: auto !important;
    min-height: 64px !important;
    border-radius: 14px !important;
  }

  /* Icon container — left, fixed size */
  .related-tools-section .card > div:first-child {
    flex-shrink: 0 !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
  }

  /* Tool name — middle, single line */
  .related-tools-section .card > div:nth-child(2) {
    flex: 1 !important;
    min-width: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin-bottom: 0 !important;
  }

  /* Description — hide on mobile */
  .related-tools-section .card > div:nth-child(3) {
    display: none !important;
  }
}

/* ============================================================
   CHANGE 6 — SEO content: collapsed behind Read More toggle
   ============================================================ */
@media (max-width: 768px) {
  .seo-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
  }

  .seo-content.expanded {
    max-height: 10000px;
  }

  .seo-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--color-input-bg);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    margin: 16px 0;
  }
}

@media (min-width: 769px) {
  .seo-toggle-btn {
    display: none !important;
  }
}

/* ============================================================
   CHANGE 7 — Footer: 2-column layout on mobile
   ============================================================ */
@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 24px 16px !important;
  }

  .footer-brand {
    grid-column: 1 / -1 !important;
    margin-bottom: 8px !important;
  }

  .footer-brand p {
    display: none !important;
  }

  .footer-col h4 {
    font-size: 11px !important;
    letter-spacing: 0.06em !important;
    margin-bottom: 10px !important;
  }

  .footer-col a,
  .footer-col li {
    font-size: 13px !important;
    line-height: 2 !important;
  }

  .footer-bottom {
    flex-direction: column !important;
    gap: 4px !important;
    text-align: center !important;
    font-size: 12px !important;
    align-items: center !important;
  }
}

/* ============================================================
   CHANGE 8 — Ad placeholders: scale correctly on mobile
   ============================================================ */
@media (max-width: 768px) {
  .ad-placeholder.ad-leaderboard {
    width: 100% !important;
    max-width: 100% !important;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    font-size: 11px !important;
  }

  .ad-wrapper-rectangle {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 16px 0 !important;
  }

  .ad-rectangle-inner {
    width: 100% !important;
    max-width: 100% !important;
  }

  .ad-placeholder.ad-rectangle {
    width: 100% !important;
    max-width: 100% !important;
    height: 250px !important;
    min-height: 250px !important;
    max-height: 250px !important;
  }
}

/* ============================================================
   FIX 1 — Search bar: unified pill shape on mobile
   ============================================================ */
@media (max-width: 768px) {
  /* The inner pill container becomes the unified rounded border */
  .search-bar {
    border-radius: 14px !important;
    overflow: hidden !important;
    background: var(--color-input-bg) !important;
    border: 1.5px solid var(--border) !important;
    box-shadow: none !important;
  }

  .search-input {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .search-btn {
    border-radius: 0 !important;
    border: none !important;
    flex-shrink: 0 !important;
    background: var(--yellow) !important;
    height: 100% !important;
    padding: 0 20px !important;
  }
}

/* ============================================================
   FIX 2 — Homepage category cards: 2-column compact grid on mobile
   ============================================================ */
@media (max-width: 768px) {
  .cat-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  .cat-card {
    height: auto !important;
    min-height: 140px !important;
    padding: 14px !important;
    border-radius: 16px !important;
  }

  .cat-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 16px !important;
    margin-bottom: 8px !important;
  }

  .cat-icon svg {
    width: 18px !important;
    height: 18px !important;
  }

  .cat-title {
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    margin-bottom: 4px !important;
  }

  .cat-desc {
    display: none !important;
  }

  .cat-cta {
    font-size: 11px !important;
    padding: 5px 10px !important;
    border-radius: 999px !important;
    margin-top: auto !important;
  }
}

/* ============================================================
   FIX 3 — Category pages: hide CTA banner on mobile
   ============================================================ */
@media (max-width: 768px) {
  .cta-banner {
    display: none !important;
  }
}

/* ============================================================
   FIX 4 — Calculator pages: restore $ prefix padding on mobile
   The mobile iOS input rule (Change 2) sets padding: 0 16px !important
   which overrides the inline padding-left:28px on currency inputs.
   This restores the left padding so placeholder text clears the $ symbol.
   ============================================================ */
@media (max-width: 768px) {
  input[style*="padding-left:28px"] {
    padding-left: 28px !important;
  }
}

/* ============================================================
   FIX 5 — Dark mode: unified search bar styling (all screen sizes)
   ============================================================ */
[data-theme="dark"] .search-bar {
  background: var(--color-input-bg) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}

[data-theme="dark"] .search-input {
  background: transparent !important;
  color: var(--ink) !important;
}

[data-theme="dark"] .search-input::placeholder {
  color: var(--slate) !important;
}

[data-theme="dark"] .search-btn {
  background: var(--yellow) !important;
  color: #1E2026 !important;
}

/* Desktop: ensure search button right edge matches the pill wrapper */
.search-bar {
  overflow: hidden;
}
.search-btn {
  border-radius: 0;
}
