/* ═══════════════════════════════════════════════════════════════════
   RENTADOMUS — Mobile Responsive
   Breakpoints: tablet ≤ 1024px | tablet-sm ≤ 768px | mobile ≤ 480px | small ≤ 380px
   ═══════════════════════════════════════════════════════════════════ */

/* ── Base touch improvements ──────────────────────────────────────── */
@media (max-width: 768px) {
  /* Better tap targets */
  button, a, [role="button"] { min-height: 44px; }

  /* Prevent horizontal overflow globally */
  html, body { overflow-x: hidden; max-width: 100vw; }
  * { box-sizing: border-box; }

  /* Glass cards full-width on mobile */
  .nl-glass-card {
    border-radius: 12px;
    margin: 0 0 1rem;
    padding: 1.25rem;
  }

  /* Buttons full-width stacked */
  .nl-button-group {
    flex-direction: column;
    gap: .75rem;
  }
  .nl-button-group button,
  .nl-button-group a {
    width: 100%;
    justify-content: center;
  }

  /* Forms: full-width inputs */
  .nl-input, sl-input, sl-select, sl-textarea { width: 100%; }

  /* Two-column grids → single column */
  .nl-grid-2, .dos-dash-grid, .property-grid {
    grid-template-columns: 1fr !important;
  }

  /* Nav items spacing */
  .nl-nav { padding: 0 1rem; }

  /* Wizard steps */
  .nl-step-indicator { font-size: .75rem; }
}

/* ── CTA buttons large modifier ───────────────────────────────────── */
.rd-btn--lg {
  font-size: 1.05rem;
  padding: 17px 36px;
}
@media (max-width: 768px) {
  .rd-btn--lg {
    font-size: 1rem !important;
    padding: 16px 24px !important;
    width: 100%;
    justify-content: center;
  }
}

/* ── Mini-stat 2-col grid (home.html §6) ──────────────────────────── */
.rd-mini-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
/* Already 2 small cards — stays 2-col down to 360px, fine */

/* ── Stat 2x2 grid (Rentalmatch.html) ────────────────────────────── */
.rd-stat-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 400px) {
  .rd-stat-grid-2x2 {
    grid-template-columns: 1fr;
  }
  .rd-stat-grid-2x2 > div {
    padding: 20px !important;
  }
  .rd-stat-grid-2x2 > div > div:first-child {
    font-size: 2.4rem !important;
  }
}

/* ── Score bar overflow fix ───────────────────────────────────────── */
@media (max-width: 380px) {
  .rd-score-bar { flex-wrap: wrap; gap: 4px; }
  .rd-score-bar-name { width: 100%; text-align: left; font-size: 0.72rem; }
  .rd-score-bar-track { flex: 1; min-width: 60px; }
  .rd-score-bar-val { width: auto; }
}

/* ── Dossier dashboard mobile ─────────────────────────────────────── */
@media (max-width: 768px) {
  .dos-dashboard { padding: 1rem; }
  .dos-dash-card { padding: 1rem; border-radius: 12px; }
  .dos-dash-card-head { flex-wrap: wrap; gap: .5rem; }
  .dos-card-actions { flex-direction: column; gap: .5rem; width: 100%; }
  .dos-card-actions button { width: 100%; justify-content: center; }
  .aff-widget { padding: 1rem; }
  .aff-widget-inner { gap: .75rem; }
  .aff-icon { font-size: 1.5rem; }
  .aff-amount { font-size: 1.3rem; }
  .dos-invites-section { padding: 0; }
  .docs-modal-inner, .invite-modal-inner {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
}

/* ── Property detail mobile ───────────────────────────────────────── */
@media (max-width: 768px) {
  .detail-layout { flex-direction: column !important; gap: 1rem; }
  .detail-main, .detail-sidebar { width: 100% !important; max-width: 100% !important; }
  .detail-gallery { border-radius: 12px; overflow: hidden; }
  .detail-price { font-size: 1.6rem; }
  .detail-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
    text-align: center;
  }
  .apply-btn { font-size: .95rem; padding: .8rem; }
  .app-card-head { flex-direction: column; gap: .5rem; }
  .app-score-badge { align-self: flex-start; }
  .app-card-body { flex-direction: column; gap: .25rem; }
}

/* ── Rentalvetrina (property listings) mobile ─────────────────────── */
@media (max-width: 768px) {
  .vetrina-layout { flex-direction: column !important; }
  .vetrina-map { height: 260px !important; width: 100% !important; border-radius: 12px; overflow: hidden; }
  .vetrina-filters { padding: 1rem; gap: .75rem; }
  .filter-grid { grid-template-columns: 1fr 1fr !important; gap: .5rem; }
  .property-card { border-radius: 12px; }
  .property-card-metrics { flex-wrap: wrap; gap: .4rem; }

  /* Vetrina hero stat bar */
  .rv-hero-stats { gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
  .rv-hero-stat { min-width: 60px; }
  .rv-hero-stat-sep { display: none; }
}

/* ── New listing wizard mobile ────────────────────────────────────── */
@media (max-width: 768px) {
  .listing-wizard { padding: 1rem; }
  .listing-step-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .listing-grid-2 { grid-template-columns: 1fr !important; }
  .listing-photo-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── Auth pages mobile ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 1.5rem 1.25rem; margin: 1rem; border-radius: 16px; }
  .auth-logo { font-size: 1.5rem; }
}

/* ── Navigation mobile ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nl-bottom-nav { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .mobile-sticky-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(10,15,30,.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,.08);
    padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    display: flex;
    gap: .75rem;
  }
  .mobile-sticky-bar button { flex: 1; }
}

/* ── Product pages: hero section top padding fix ─────────────────── */
/* On very small phones the clamp 120px bottom is already correct,
   but we add safe area for notched phones */
@media (max-width: 768px) {
  .rd-section[style*="padding-top"] {
    padding-top: max(100px, env(safe-area-inset-top, 0px) + 100px) !important;
  }
  /* Simpler: just use the natural hero padding-top */
  section.rd-section.rd-bg-1:first-of-type {
    padding-top: clamp(100px, 20vw, 140px) !important;
  }
}

/* ── Product pages: inline-styled callout in Rentalscore ──────────── */
@media (max-width: 480px) {
  /* "Livelli di score" panel — already flex-column, just ensure padding */
  .rd-two-col > div > div[style*="padding:clamp"] {
    padding: 20px !important;
  }
}

/* ── Trust bar on small screens ───────────────────────────────────── */
@media (max-width: 480px) {
  .trust-stat { flex: 1 1 100%; }
  .trust-bar-sep { display: none; }
}

/* ── HiW tabs on small mobile ─────────────────────────────────────── */
@media (max-width: 480px) {
  .hiw-tabs {
    width: calc(100vw - 48px);
    border-radius: 16px;
    flex-direction: column;
    padding: 6px;
    gap: 4px;
  }
  .hiw-tab { justify-content: center; border-radius: 12px; }
}

/* ── Tablet (768–1024px) ──────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .dos-dash-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .detail-layout { flex-direction: row; gap: 1.5rem; }
  .detail-sidebar { width: 340px; flex-shrink: 0; }
  .filter-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ── Small phones (≤ 380px) ──────────────────────────────────────── */
@media (max-width: 380px) {
  .nl-glass-card { padding: 1rem; }
  .aff-amount { font-size: 1.15rem; }
  .filter-grid { grid-template-columns: 1fr !important; }

  /* Hero action cards: smaller padding */
  .hero-action-card { padding: 14px 16px; gap: 10px; }
  .hero-action-text { font-size: 0.88rem; }

  /* Dossier card: scale down slightly */
  .adc-ring-wrap { width: 88px; height: 88px; }
  .adc-ring-svg  { width: 88px; height: 88px; }
  .adc-ring-num  { font-size: 1.6rem; }
  .adc-score-grade { font-size: 1rem; }

  /* Product page section padding */
  .rd-section { padding: clamp(44px, 9vw, 64px) 0; }

  /* Buttons: slightly smaller */
  .rd-btn { padding: 14px 20px; font-size: 0.93rem; }
}

/* ── Landscape phones ─────────────────────────────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  .vetrina-map { height: 200px !important; }
  .auth-card { margin: .5rem auto; }
  .hero-section { min-height: auto !important; padding: 60px 20px 40px; }
  .rd-section { padding: clamp(40px, 8vw, 60px) 0; }
}

/* ── iOS safe area ────────────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .home-footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .rd-cookie-banner { bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ── Prevent content overflow ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Long words / URLs in text */
  .rd-lead, .rd-flist li, .rd-step-text, .rd-callout-text,
  .rd-gdpr-text, .rd-product-desc, .rd-cat-desc, p {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Images responsive by default */
  img { max-width: 100%; height: auto; }

  /* Tables overflow scroll */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Callout icon stays aligned */
  .rd-callout { align-items: flex-start; }
  .rd-callout-icon { margin-top: 2px; flex-shrink: 0; }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE — GENERAL SECTION OVERFLOW PROTECTION
   (Prevent horizontal scrollbar / content getting clipped)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* All sections: no horizontal overflow */
  .rd-section,
  .hero-section,
  section {
    overflow-x: hidden;
  }

  /* Two-col: proper stacking and no min-width overflow */
  .rd-two-col,
  .rd-two-col--60-40,
  .rd-two-col--reverse {
    grid-template-columns: 1fr !important;
    gap: 32px;
  }

  /* AI dossier card: prevent transform overflow */
  .ai-dossier-card {
    transform: none !important;
    animation: none !important;
    max-width: calc(100vw - 40px);
    margin: 0 auto;
  }

  /* Rep card: full width on mobile */
  .rd-rep-card {
    max-width: calc(100vw - 40px);
    margin: 0 auto;
  }

  /* Benefits grid: single column */
  .rd-benefits-grid {
    grid-template-columns: 1fr;
  }

  /* Prevent any card from overflowing its section */
  .rd-benefit-card,
  .rd-split,
  .rd-step,
  .rd-product-card {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
  }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE — SEARCH BAR  (keep pill shape on mobile)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hero-search-wrap {
    width: calc(100vw - 32px) !important;
  }
  .hero-search {
    flex-direction: row !important;
    border-radius: 50px !important;
    padding: 6px 6px 6px 18px !important;
    gap: 8px !important;
    align-items: center !important;
  }
  .hero-search #search-input {
    font-size: 0.9rem;
    width: 0;       /* let flex grow it */
    flex: 1 1 auto;
    min-width: 0;
  }
  .hero-search-btn {
    width: auto !important;
    padding: 10px 16px !important;
    border-radius: 40px !important;
    font-size: 0.88rem;
    flex-shrink: 0;
  }
  /* Re-enable search icon on mobile */
  .hero-search-icon {
    display: block !important;
    flex-shrink: 0;
  }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE — HERO TITLE  spacing from navbar
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hero-section {
    padding-top: max(110px, calc(env(safe-area-inset-top) + 80px)) !important;
    padding-bottom: 60px !important;
  }
}
@media (max-width: 400px) {
  .hero-section {
    padding-top: 100px !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   HOME PAGE — SEZIONE PER SEZIONE  mobile audit completo
   ══════════════════════════════════════════════════════════════ */

/* ─── §1 HERO ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Scroll cue: hide on very small screens to save space */
  .hero-scroll-cue { margin-top: 28px; }

  /* CTAs: ensure full width readability */
  .hero-cta-pair { gap: 10px; }
  .hero-cta { border-radius: 16px; }
}

/* ─── §2 BENEFITS OVERVIEW (rd-light) ─────────────────────── */
@media (max-width: 580px) {
  .rd-benefits-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 28px;
  }
  .rd-benefit-card { padding: 22px 18px 18px; border-radius: 14px; }
  .rd-benefit-icon { width: 46px; height: 46px; border-radius: 12px; margin-bottom: 14px; }
  .rd-benefit-card .rd-h3 { font-size: 1rem; }
  .rd-benefit-text { font-size: 0.875rem; margin-bottom: 14px; }
  .rd-benefit-tag { font-size: 0.68rem; padding: 4px 10px; }
}

/* ─── §3 AI SECTION ────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Reduce the giant statement heading */
  .ai-statement {
    font-size: clamp(2rem, 7.5vw, 3.5rem) !important;
    line-height: 1.05 !important;
    letter-spacing: -0.03em !important;
    text-wrap: balance;
  }
  .ai-inner {
    grid-template-columns: 1fr !important;
    gap: 36px !important;
    max-width: 100% !important;
  }
  .ai-headline {
    font-size: clamp(1.7rem, 7vw, 2.4rem) !important;
    line-height: 1.1 !important;
  }
  .ai-subtext {
    font-size: 0.95rem !important;
    max-width: 100% !important;
  }
  .ai-pills {
    gap: 8px;
  }
  .ai-pill {
    font-size: 0.82rem;
    padding: 7px 12px;
  }
  .ai-visual {
    width: 100%;
    overflow: hidden;
  }
  /* Dossier card on mobile */
  .ai-dossier-card {
    width: 100% !important;
    max-width: calc(100vw - 40px) !important;
    transform: none !important;
    animation: none !important;
  }
}
@media (max-width: 480px) {
  .ai-statement {
    font-size: clamp(1.75rem, 7vw, 2.8rem) !important;
  }
  .adc-rows { padding: 6px 14px 2px; }
  .adc-row { font-size: 0.78rem; padding: 8px 0; }
  .adc-header { padding: 14px 14px 10px; gap: 10px; }
  .adc-avatar { width: 36px; height: 36px; font-size: 0.8rem; border-radius: 10px; }
  .adc-name { font-size: 0.9rem; }
  .adc-score-band { padding: 0 14px 8px; gap: 12px; }
  .adc-ring-wrap { width: 80px; height: 80px; }
  .adc-ring-svg  { width: 80px; height: 80px; }
  .adc-ring-num  { font-size: 1.5rem; }
  .adc-footer { padding: 10px 14px; }
}

/* ─── §4 PROPRIETARI (rd-light) ───────────────────────────── */
@media (max-width: 768px) {
  .rd-callout {
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border-radius: 14px;
  }
  .rd-callout-icon { width: 28px; height: 28px; }
  .rd-callout-title { font-size: 0.95rem; }
  .rd-callout-text  { font-size: 0.85rem; line-height: 1.6; }

  /* Mini stat grid */
  .rd-mini-grid-2 { gap: 10px; }
  .rd-stat-mini { padding: 18px 14px; border-radius: 12px; }
  .rd-stat-mini-num { font-size: 1.8rem; }
  .rd-stat-mini-label { font-size: 0.72rem; }
}

/* ─── §5 SEPA (rd-bg-0) ────────────────────────────────────── */
@media (max-width: 480px) {
  .rd-sepa-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
  }
  .rd-sepa-month  { font-size: 0.82rem; }
  .rd-sepa-amount { font-size: 0.95rem; }
  .rd-sepa-status { align-self: flex-start; font-size: 0.68rem; }
}

/* ─── §6 DOSSIER (rd-light) ────────────────────────────────── */
@media (max-width: 768px) {
  .rd-steps { gap: 0; }
  .rd-step { padding: 16px 0; gap: 12px; }
  .rd-step-num { font-size: 2rem; min-width: 40px; }
  .rd-step-title { font-size: 0.95rem; }
  .rd-step-text  { font-size: 0.84rem; line-height: 1.6; }
}

/* ─── §7 RENTALSCORE rep card ──────────────────────────────── */
@media (max-width: 768px) {
  .rd-rep-card { border-radius: 18px; }
  .rd-rep-hero { padding: 22px 22px 16px; gap: 18px; }
  /* Month bars: 12-col stays, just smaller */
  .rd-rep-months { gap: 4px; padding: 0 22px 16px; }
  .rd-rep-bar { height: 26px; border-radius: 3px; }
  .rd-rep-month span { font-size: 0.54rem; }
  .rd-rep-stats { padding: 14px 22px; }
  .rd-rep-stat-num { font-size: 1.3rem; }
  .rd-rep-section-title { padding: 14px 22px 8px; }
  .rd-rep-footer { padding: 12px 22px; }
}
@media (max-width: 480px) {
  .rd-rep-hero { padding: 18px 16px 12px; gap: 14px; }
  .rd-rep-score-ring { width: 86px; height: 86px; }
  .rd-rep-ring-svg { width: 86px; height: 86px; }
  .rd-rep-score-ring .rd-rep-score-num { font-size: 2rem; }
  .rd-rep-name { font-size: 1.2rem; }
  .rd-rep-city { font-size: 0.78rem; }
  .rd-rep-months,
  .rd-rep-stats,
  .rd-rep-section-title,
  .rd-rep-footer { padding-left: 16px; padding-right: 16px; }
  .rd-rep-bar { height: 22px; }
  .rd-rep-month span { font-size: 0.50rem; }
  .rd-rep-stats { flex-wrap: wrap; gap: 12px; justify-content: center; }
  .rd-rep-stat-divider { display: none; }
  .rd-rep-stat { min-width: 70px; }
}

/* ─── §8 PRIVACY (rd-light) ────────────────────────────────── */
@media (max-width: 768px) {
  /* Split cards visible on white background */
  .rd-split { gap: 12px; }
}
@media (max-width: 600px) {
  .rd-split { grid-template-columns: 1fr !important; gap: 12px; }
  .rd-split-card { padding: 18px; border-radius: 12px; }
  .rd-split-label { font-size: 0.72rem; margin-bottom: 10px; }
  .rd-split-items li { font-size: 0.85rem; padding: 8px 0; }
}

/* ─── §9 ECOSYSTEM ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .rd-product-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .rd-product-card { padding: 22px 20px; border-radius: 16px; }
  .rd-product-icon { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px; }
  .rd-product-name { font-size: 1.15rem; }
  .rd-product-desc { font-size: 0.84rem; }
}

/* ─── §10 CTA FINALE ───────────────────────────────────────── */
@media (max-width: 768px) {
  .rd-cta-section { text-align: center; }
  .rd-cta-btns {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    max-width: 360px;
    margin: 0 auto;
  }
  .rd-cta-btns .rd-btn { width: 100%; justify-content: center; }
}

/* ─── GENERAL: rd-light text on white ─────────────────────── */
@media (max-width: 768px) {
  /* Ensure lead text is readable in light sections */
  .rd-light .rd-lead { color: #424b6a !important; }
  .rd-light .rd-flist li { color: #2a3550; }
  .rd-light .rd-h2, .rd-light .rd-h3 { color: #0a0e1a; }

  /* Container padding: never touches edges */
  .rd-container {
    padding-left: max(20px, env(safe-area-inset-left)) !important;
    padding-right: max(20px, env(safe-area-inset-right)) !important;
  }
}
