/*
  iubenda Cookie Solution — GrowApps banner styling (companion to
  cookie_banner.js, which sets position/colors via _iub.csConfiguration).

  iubenda injects its own stylesheet AFTER ours, so a plain !important rule
  loses the tie; every override below repeats a class to out-specify theirs
  (same trick as the badge rule at the bottom). Class names verified against
  cookie_solution/iubenda_cs 1.102.x DOM — re-verify in devtools if iubenda
  bumps a major version.

  Colors come from GrowAppsTheme (frontend/lib/theme.dart), dark palette.
*/

/*
  iubenda pins the floating card to width:480px via a higher-specificity
  rule (computed max-width stays "none" without the doubled classes), so
  override width itself, not just max-width.
*/
#iubenda-cs-banner .iubenda-cs-container.iubenda-cs-container.iubenda-cs-container {
  width: 260px !important;
  max-width: 260px !important;
  margin: 0 16px 16px 0 !important;
}
#iubenda-cs-banner .iubenda-cs-content.iubenda-cs-content.iubenda-cs-content {
  border-radius: 20px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5) !important;
  padding: 16px 18px !important;
  font-size: 12px !important;
}
#iubenda-cs-banner .iubenda-cs-rationale { padding: 0 !important; }

/*
  Kill iubenda's own inner spacing, which stacks on top of the
  .iubenda-cs-content padding (16px pad on the text block, 40px top margin
  on its first child, 16px margins around the button group) and leaves the
  card with big dead zones.
*/
#iubenda-cs-banner .iubenda-banner-content.iubenda-banner-content { padding: 0 !important; margin: 0 0 10px !important; }
#iubenda-cs-banner .iubenda-banner-content > div:first-child { margin-top: 0 !important; }
#iubenda-cs-banner .iubenda-banner-content,
#iubenda-cs-banner .iubenda-banner-content p {
  font-size: 12px !important;
  line-height: 1.5 !important;
  margin: 0 0 10px !important;
}

/* Links in sprout green (GrowAppsTheme.darkSecondary) */
#iubenda-cs-banner a { color: #6FD49B !important; }

/*
  Lovable-style stacked actions: Accept is the single full-width filled
  pill; Reject and "Learn more and customize" render as quiet text-only
  buttons beneath it (still real, same-tap-count actions — GDPR parity).
*/
#iubenda-cs-banner .iubenda-cs-opt-group.iubenda-cs-opt-group {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 2px !important;
  margin: 0 !important;
}
#iubenda-cs-banner .iubenda-cs-opt-group button,
#iubenda-cs-banner .iubenda-cs-opt-group a {
  border-radius: 999px !important;
  font-size: 12px !important;
  padding: 8px 16px !important;
  width: 100% !important;
  margin: 0 !important;
  text-align: center !important;
}

/*
  The opt-group nests two wrappers: .iubenda-cs-opt-group-consent
  (Reject + Accept, side by side by default) and .iubenda-cs-opt-group-custom
  (the customize link). Make both columns and reorder so it reads
  Accept / Reject / customize, like Lovable.
*/
#iubenda-cs-banner .iubenda-cs-opt-group-consent.iubenda-cs-opt-group-consent,
#iubenda-cs-banner .iubenda-cs-opt-group-custom.iubenda-cs-opt-group-custom {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 2px !important;
  margin: 0 !important;
}
#iubenda-cs-banner .iubenda-cs-opt-group-consent.iubenda-cs-opt-group-consent { order: 1; }
#iubenda-cs-banner .iubenda-cs-opt-group-custom.iubenda-cs-opt-group-custom { order: 2; }
#iubenda-cs-banner .iubenda-cs-accept-btn.iubenda-cs-accept-btn { order: 1; }
#iubenda-cs-banner .iubenda-cs-reject-btn.iubenda-cs-reject-btn { order: 2; background: transparent !important; color: #A7B5A0 !important; }
#iubenda-cs-banner .iubenda-cs-customize-btn.iubenda-cs-customize-btn { background: transparent !important; }

/*
  Hide iubenda's floating "Privacy Controls" corner badge: the in-app support
  bubble (lib/widgets/support_chat/) took over that corner. The consent
  BANNER itself is untouched — only the persistent badge is hidden. Consent
  choices stay reachable via the support panel's "Cookie preferences" link,
  which calls _iub.cs.api.openPreferences(); keep that link as long as this
  rule exists (a way to reopen preferences is a GDPR requirement).

  The class is repeated to out-specify iubenda's own injected
  `display:inline-block !important` rule (verified live: their selector
  weighs (0,3,0), this weighs (0,5,0) — both !important, higher wins).
*/
.iubenda-tp-btn.iubenda-tp-btn.iubenda-tp-btn.iubenda-tp-btn[data-tp-float] { display: none !important; }

/*
  Suppress the auto-popup banner itself (product decision: the Terms of
  Service / Privacy Policy acknowledgment already shown on every sign-up —
  see hero_auth_gate.dart / auth_prompt_dialog.dart — is treated as
  sufficient upfront notice; the banner's own interruption is redundant on
  top of it). Everything it would otherwise gate stays exactly as-is:
  autoblocking, consent logging, the growConsent bridge, and the
  preferences panel (#iubenda-iframe, untouched below) are all still wired
  up — visitors who never open preferences simply stay in the default
  cookieless/anonymous state, which is the privacy-safe outcome anyway.
  Reachable via "Cookie preferences" in the account screen and the support
  chat footer, both of which call _iub.cs.api.openPreferences() and must
  keep working as long as this rule exists.

  The id is doubled to out-specify iubenda's own injected rule on the same
  selector (`#iubenda-cs-banner { display: flex !important }`, added via a
  dynamically-injected <style> tag that loads AFTER this stylesheet) — equal
  specificity + equal !important is broken by source order, and theirs
  currently comes later, so a plain `#iubenda-cs-banner` here loses. Verified
  live: doubling raises specificity from (1,0,0) to (2,0,0), which wins
  regardless of injection order. Same trick as the badge rule above.
*/
#iubenda-cs-banner#iubenda-cs-banner { display: none !important; }

/* ────────────────────────────────────────────────────────────────────────
   Preferences panel ("Your Privacy Choices", opened via Learn more /
   openPreferences). Renders IN-PAGE under div#iubenda-iframe (no real
   iframe, verified live), so plain CSS reaches it. Same garden-dark theme
   as the banner; structure verified against iubenda_cs 1.102.x DOM.
   ──────────────────────────────────────────────────────────────────────── */

/* Modal shell: dark surface, rounded like the banner card. The doubled
   ids/classes out-specify iubenda's own !important rules on the same
   elements (their sheet loads after ours). */
#iubenda-iframe #iubenda-iframe-popup#iubenda-iframe-popup,
#iubenda-iframe #iubenda-iframe-content#iubenda-iframe-content,
#iubenda-iframe #purposes-container#purposes-container,
#iubenda-iframe #purposes-content-container#purposes-content-container,
#iubenda-iframe .iubenda-iframe-top-container.iubenda-iframe-top-container,
#iubenda-iframe .iub-consent-buttons.iub-consent-buttons,
#iubenda-iframe .purposes-section-body.purposes-section-body,
#iubenda-iframe .iubenda-iframe-footer.iubenda-iframe-footer,
#iubenda-iframe .purposes-content,
#iubenda-iframe .purposes-body,
#iubenda-iframe .purposes-section {
  background: #161D13 !important;        /* darkSurface */
  color: #A7B5A0 !important;             /* darkTextMuted */
  box-shadow: none !important;
}
#iubenda-iframe #iubenda-iframe-popup#iubenda-iframe-popup#iubenda-iframe-popup {
  border-radius: 20px !important;
  overflow: hidden !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5) !important;
  /* Slimmer modal than iubenda's default (~720px); stays centered */
  width: min(480px, calc(100vw - 32px)) !important;
  max-width: min(480px, calc(100vw - 32px)) !important;
}
#iubenda-iframe .purposes-header {
  background: #12180F !important;        /* darkBg1 */
  border-bottom: 1px solid #1F271B !important;
}

/* Type: pale leaf headings, sage body, sprout-green links */
#iubenda-iframe h2.purposes-header-title,
#iubenda-iframe h3.purposes-section-header-title,
#iubenda-iframe .purposes-item-title,
#iubenda-iframe .purposes-item-title-btn {
  color: #EAF1EA !important;             /* darkText */
}
#iubenda-iframe p, #iubenda-iframe label { color: #A7B5A0 !important; }
/* "See/Hide description" expander + the expanded description body render
   near-black by default (their higher-specificity rule wins over the block
   above) — force sage, including the chevron icon */
#iubenda-iframe#iubenda-iframe .purposes-item-title-btn.purposes-item-title-btn,
#iubenda-iframe#iubenda-iframe .purposes-item-title-btn.purposes-item-title-btn * {
  color: #A7B5A0 !important;
  fill: #A7B5A0 !important;
  stroke: #A7B5A0 !important;
}
#iubenda-iframe#iubenda-iframe .purposes-item-body.purposes-item-body,
#iubenda-iframe#iubenda-iframe .purposes-item-body.purposes-item-body p {
  color: #A7B5A0 !important;
}
#iubenda-iframe#iubenda-iframe a { color: #6FD49B !important; }

/* Dark scrollbar inside the panel (default white bar glares on the dark bg) */
#iubenda-iframe *::-webkit-scrollbar { width: 8px; }
#iubenda-iframe *::-webkit-scrollbar-track { background: #161D13; }
#iubenda-iframe *::-webkit-scrollbar-thumb { background: #1F271B; border-radius: 999px; }

/* All panel buttons become pills; Accept-all + Save filled green,
   the rest quiet dark-stroked */
/* Their consent-button rule carries an id, so double ours too */
#iubenda-iframe#iubenda-iframe .iub-btn.iub-btn.iub-btn {
  border-radius: 999px !important;
  border-color: #1F271B !important;
  background: #1F271B !important;        /* darkSurface2 */
  background-image: none !important;     /* kills iubenda's SVG btn texture */
  color: #EAF1EA !important;
  box-shadow: none !important;
}
/* "Save and continue" is a classless <button> inside #iubFooterBtnContainer */
#iubenda-iframe#iubenda-iframe .iub-btn.purposes-btn-accept.purposes-btn-accept,
#iubenda-iframe #iubFooterBtnContainer#iubFooterBtnContainer button {
  background: #6FD49B !important;        /* darkSecondary */
  background-image: none !important;
  border-color: #6FD49B !important;
  border-radius: 999px !important;
  color: #12180F !important;
}

/* Purpose rows paint white via a linear-gradient background-image (not
   background-color) on their headers — swap it for the flat dark surface */
#iubenda-iframe#iubenda-iframe .purposes-item-header.purposes-item-header,
#iubenda-iframe#iubenda-iframe .purposes-item.purposes-item,
#iubenda-iframe#iubenda-iframe .purposes-item-body.purposes-item-body {
  background-image: none !important;
  background-color: #1F271B !important;  /* darkSurface2: rows read as cards */
}
#iubenda-iframe#iubenda-iframe .purposes-item.purposes-item {
  border-radius: 12px !important;
  margin-bottom: 6px !important;
  border: none !important;
}

/* Purpose toggles: sprout green when on */
#iubenda-iframe input.style1 { accent-color: #6FD49B !important; }
#iubenda-iframe input.style1:checked,
#iubenda-iframe input.style1:checked + label { background-color: #6FD49B !important; }
