/* ==========================================================================
   RL Solar — brand theme layered on Bootstrap 5
   Tokens taken from the Claude Design mockup (design-reference/).
   ========================================================================== */

:root {
  /* Brand palette */
  --rl-blue: #179BD3;
  --rl-blue-600: #177DAA;
  --rl-blue-800: #135c82;
  --rl-blue-050: #EBF6FB;
  --rl-amber: #FEBA1B;
  --rl-amber-600: #F19D06;
  --rl-amber-800: #cc8404;
  --rl-green: #B5D348;
  --rl-green-600: #88a629;
  --rl-ink: #1a2b3c;
  --rl-slate: #4a5568;
  --rl-muted: #67707d;   /* ~4.6:1 on white — WCAG AA for small text (was #8896a0 ≈3:1) */
  --rl-line: #e8edf2;
  --rl-surface: #F5F8FA;

  /* Map Bootstrap semantic colors onto the brand */
  --bs-primary: var(--rl-blue);
  --bs-primary-rgb: 23, 155, 211;
  --bs-warning: var(--rl-amber);
  --bs-warning-rgb: 254, 186, 27;
  --bs-success: var(--rl-green);
  --bs-success-rgb: 181, 211, 72;
  --bs-body-color: var(--rl-ink);
  --bs-body-font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-link-color-rgb: 23, 125, 170;
  --bs-border-color: var(--rl-line);
}

body {
  font-family: var(--bs-body-font-family);
  color: var(--rl-ink);
  background: #fff;
}

/* --- Buttons ------------------------------------------------------------- */
.btn-primary {
  --bs-btn-bg: var(--rl-blue);
  --bs-btn-border-color: var(--rl-blue);
  --bs-btn-hover-bg: var(--rl-blue-600);
  --bs-btn-hover-border-color: var(--rl-blue-600);
  --bs-btn-active-bg: var(--rl-blue-800);
  --bs-btn-active-border-color: var(--rl-blue-800);
  --bs-btn-disabled-bg: var(--rl-blue);
  --bs-btn-disabled-border-color: var(--rl-blue);
  font-weight: 700;
}

.btn-outline-primary {
  --bs-btn-color: var(--rl-blue-600);
  --bs-btn-border-color: var(--rl-blue);
  --bs-btn-hover-bg: var(--rl-blue);
  --bs-btn-hover-border-color: var(--rl-blue);
  --bs-btn-active-bg: var(--rl-blue-600);
  font-weight: 700;
}

/* Amber CTA — the mockup's primary call-to-action */
.btn-accent {
  --bs-btn-color: var(--rl-ink);
  --bs-btn-bg: var(--rl-amber);
  --bs-btn-border-color: var(--rl-amber);
  --bs-btn-hover-color: var(--rl-ink);
  --bs-btn-hover-bg: var(--rl-amber-600);
  --bs-btn-hover-border-color: var(--rl-amber-600);
  --bs-btn-active-bg: var(--rl-amber-800);
  color: var(--rl-ink);
  font-weight: 800;
  box-shadow: 0 4px 18px rgba(241, 157, 6, .35);
}

/* --- Brand text / surfaces ---------------------------------------------- */
.text-brand { color: var(--rl-blue) !important; }
.text-brand-600 { color: var(--rl-blue-600) !important; }
.text-amber { color: var(--rl-amber-600) !important; }
.text-ink { color: var(--rl-ink) !important; }
.text-slate { color: var(--rl-slate) !important; }
.text-muted-2 { color: var(--rl-muted) !important; }
.fw-black { font-weight: 900 !important; }
.bg-surface { background: var(--rl-surface) !important; }
.bg-brand-050 { background: var(--rl-blue-050) !important; }
.border-line { border-color: var(--rl-line) !important; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--rl-blue-050);
  border: 1px solid rgba(23, 157, 211, .2);
  border-radius: 99px;
  padding: .35rem 1rem;
  font-size: .75rem;
  font-weight: 700;
  color: var(--rl-blue-600);
}
.chip .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--rl-green); }

/* --- Category gradient tiles (product imagery placeholder) --------------- */
.cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  overflow: hidden;
  position: relative;
}
.img-paneles     { background: linear-gradient(135deg, #179BD3, #177DAA); }
.img-inversores  { background: linear-gradient(135deg, #177DAA, #135c82); }
.img-baterias    { background: linear-gradient(135deg, #FEBA1B, #F19D06); }
.img-kits        { background: linear-gradient(135deg, #B5D348, #88a629); }
.img-estructuras { background: linear-gradient(135deg, #F19D06, #cc8404); }
.img-accesorios  { background: linear-gradient(135deg, #179BD3, #B5D348); }

/* --- Product card -------------------------------------------------------- */
.product-card {
  transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s ease;
  box-shadow: 0 1px 2px rgba(16, 42, 67, .04), 0 6px 18px rgba(16, 42, 67, .06);
  background: #fff;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 38px rgba(23, 157, 211, .18);
}
@media (prefers-reduced-motion: reduce) {
  .product-card { transition: none; }
  .product-card:hover { transform: none; }
}

.product-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--rl-surface);
}
.product-media img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .5s cubic-bezier(.22,1,.36,1);
}
.product-card:hover .product-media img { transform: scale(1.05); }
.product-media__tint { position: absolute; inset: 0; opacity: .38; mix-blend-mode: multiply; }
.product-media__label {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end;
  padding: .65rem .8rem;
  background: linear-gradient(to top, rgba(6, 24, 38, .5) 0%, rgba(6, 24, 38, .05) 45%, transparent 70%);
}
.product-media__spec {
  color: #fff; font-weight: 900; font-size: 1.1rem; letter-spacing: -.5px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .45);
}
.product-media__badge {
  position: absolute; top: .6rem; left: .6rem;
  background: #fff; color: var(--rl-blue-600);
  font-size: .6rem; font-weight: 800; letter-spacing: .3px;
  padding: .18rem .6rem; border-radius: 99px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.product-media__stock {
  position: absolute; top: .6rem; right: .6rem;
  background: rgba(6, 24, 38, .55); color: #fff;
  font-size: .6rem; font-weight: 700;
  padding: .18rem .55rem; border-radius: 99px;
  backdrop-filter: blur(4px);
}
@media (prefers-reduced-motion: reduce) {
  .product-media img, .product-card:hover .product-media img { transition: none; transform: none; }
}

/* --- Photo tiles (categories, projects) ---------------------------------- */
.photo-tile {
  position: relative;
  display: block;
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
}
.photo-tile img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .55s cubic-bezier(.22,1,.36,1);
}
.photo-tile:hover img { transform: scale(1.06); }
.photo-tile__scrim {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(6, 24, 38, .82) 0%, rgba(6, 24, 38, .25) 45%, rgba(6, 24, 38, .05) 100%);
}
.photo-tile__body {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 1rem 1.15rem;
  color: #fff;
}
.photo-tile__accent { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; }
@media (prefers-reduced-motion: reduce) {
  .photo-tile img, .photo-tile:hover img { transition: none; transform: none; }
}

/* --- Testimonials -------------------------------------------------------- */
.review-card {
  background: #fff;
  border: 1px solid var(--rl-line);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(16, 42, 67, .04);
  height: 100%;
}
.review-card__stars { color: var(--rl-amber); letter-spacing: 1px; }
.avatar-stack img {
  width: 34px; height: 34px; border-radius: 99px;
  border: 2.5px solid #fff; object-fit: cover; margin-right: -9px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
}

/* --- Payment result / Webpay voucher ------------------------------------ */
.pay-badge { width: 80px; height: 80px; }
.pay-badge svg { width: 38px; height: 38px; }
.pay-badge--ok {
  background: var(--rl-green);
  color: #fff;
  box-shadow: 0 10px 26px rgba(136, 166, 41, .38);
  animation: payPop .45s cubic-bezier(.22, 1, .36, 1) both;
}
.pay-badge--fail {
  background: #fdecec;
  color: #d64545;
  box-shadow: 0 10px 26px rgba(214, 69, 69, .18);
}
@keyframes payPop {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pay-badge--ok { animation: none; }
}

.voucher-rows > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 0;
  border-bottom: 1px dashed var(--rl-line);
}
.voucher-rows > div:last-child { border-bottom: 0; }
.voucher-rows dt { margin: 0; font-weight: 600; color: var(--rl-muted); font-size: .85rem; }
.voucher-rows dd { margin: 0; text-align: right; }

/* --- Section rhythm ------------------------------------------------------ */
.section { padding-block: clamp(3rem, 6vw, 5.5rem); }
.eyebrow-line { width: 34px; height: 3px; border-radius: 3px; background: var(--rl-amber); }

/* --- Header brand mark --------------------------------------------------- */
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--rl-blue), var(--rl-blue-600));
  display: inline-flex; align-items: center; justify-content: center;
}
.navbar-brand small { letter-spacing: 2px; }

/* --- Hero ---------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.hero__bg {
  position: absolute; inset: 0; z-index: -2;
  width: 100%; height: 100%; object-fit: cover;
}
.hero__overlay {
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(100deg,
    rgba(255, 255, 255, .96) 0%,
    rgba(255, 255, 255, .93) 32%,
    rgba(255, 255, 255, .6) 55%,
    rgba(13, 49, 68, .45) 100%);
}
.hero h1 {
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.08;
  text-wrap: balance;
}

/* --- Admin panel --------------------------------------------------------- */
.admin-body { background: var(--rl-surface); }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--rl-blue-600), var(--rl-blue-800));
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-main { flex: 1; min-width: 0; padding: 1.75rem; }
.admin-nav-link {
  display: block;
  padding: .55rem .75rem;
  border-radius: 8px;
  color: rgba(255, 255, 255, .6);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.admin-nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.admin-nav-link.active { background: rgba(255, 255, 255, .15); color: #fff; font-weight: 700; }
@media (max-width: 767.98px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; gap: .5rem; }
  .admin-sidebar nav { flex-direction: row !important; flex-wrap: wrap; }
  .admin-main { padding: 1rem; }
}

/* --- Footer -------------------------------------------------------------- */
.site-footer {
  background: linear-gradient(135deg, var(--rl-blue-600), var(--rl-blue-800));
  color: rgba(255, 255, 255, .8);
}
.site-footer a { color: rgba(255, 255, 255, .7); text-decoration: none; }
.site-footer a:hover { color: #fff; }
.site-footer .footer-eyebrow {
  font-size: .65rem; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; color: rgba(255, 255, 255, .45);
}
.site-footer { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }

/* Compact footer on phones/phablets — it's oversized when stacked to 2 cols. */
@media (max-width: 767.98px) {
  .site-footer { padding-top: 1.75rem !important; }
  .site-footer .row { --bs-gutter-y: .9rem; padding-bottom: 1rem !important; }
  .site-footer .footer-eyebrow { margin-bottom: .5rem !important; }
  .site-footer ul.list-unstyled { gap: .45rem !important; font-size: .78rem; }
  .site-footer ul.list-unstyled li { overflow-wrap: anywhere; }
  .site-footer p.small { line-height: 1.5 !important; }
}

/* ==========================================================================
   Responsive / mobile pass
   Structural adaptations for touch + narrow viewports (see docs/TODO-mobile.md).
   Bootstrap breakpoints: sm 576, md 768, lg 992.
   ========================================================================== */

/* --- Touch targets: comfortable hit areas on coarse pointers -------------- */
@media (pointer: coarse) {
  .navbar .btn,
  .offcanvas .btn { min-height: 44px; }
  .btn-sm { --bs-btn-padding-y: .45rem; }
}

/* --- Header offcanvas: full-width, tappable actions on mobile ------------- */
@media (max-width: 991.98px) {
  #mainNav .offcanvas-body .btn {
    justify-content: center;
    width: 100%;
    font-size: 1rem;
  }
  /* Admin icon button needs a label affordance when full width */
  #mainNav .offcanvas-body .nav-link { padding-block: .6rem; font-size: 1.05rem; }
}

/* --- Hero: tame the display heading + padding on small screens ------------ */
@media (max-width: 575.98px) {
  .hero { padding-top: 1.75rem !important; padding-bottom: 1.75rem !important; }
  .hero h1.display-3 { font-size: clamp(1.95rem, 8.5vw, 2.6rem); }
  .hero-stats .vr { display: none; }
  .hero-stats { gap: 1.25rem 2rem !important; }
}

/* --- Product card: keep price + buy button from colliding when narrow ----- */
.product-card { container-type: inline-size; }
.product-buy {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .5rem;
  margin-top: auto;
}
.product-buy form { margin: 0; }
@container (max-width: 215px) {
  .product-buy { flex-direction: column; align-items: stretch; gap: .5rem; }
  .product-buy form { width: 100%; }
  .product-buy .btn { width: 100%; }
}

/* --- Catalog: sort options scroll horizontally instead of wrapping -------- */
@media (max-width: 575.98px) {
  .sort-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: .5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .sort-scroll::-webkit-scrollbar { display: none; }
  .sort-scroll .btn { flex: 0 0 auto; }
}
/* Filter panel sits inside a responsive offcanvas below lg; drop the nested
   card chrome so it reads as a clean sheet on mobile. */
@media (max-width: 991.98px) {
  #filtersCanvas .filter-card {
    border: 0 !important;
    box-shadow: none;
    padding: 0 !important;
  }
}

/* --- Cart quantity stepper + remove ------------------------------------- */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--rl-line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 42, 67, .05);
}
.qty-stepper form { margin: 0; line-height: 0; }
.qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--rl-surface);
  color: var(--rl-slate);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .1s ease;
}
.qty-btn svg { width: 16px; height: 16px; }
.qty-btn:hover { background: var(--rl-blue-050); color: var(--rl-blue-600); }
.qty-btn:active { transform: scale(.88); }
/* The "+" is the primary affordance — fill it with brand on hover. */
.qty-btn--add:hover { background: var(--rl-blue); color: #fff; }
.qty-btn:focus-visible { outline: 2px solid var(--rl-blue); outline-offset: 2px; }
.qty-value {
  min-width: 2.5rem;
  text-align: center;
  font-weight: 800;
  color: var(--rl-ink);
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.cart-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--rl-muted);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .1s ease;
}
.cart-remove svg { width: 16px; height: 16px; }
.cart-remove:hover { background: #fdecec; color: #d64545; }
.cart-remove:active { transform: scale(.88); }
.cart-remove:focus-visible { outline: 2px solid #d64545; outline-offset: 2px; }

@media (pointer: coarse) {
  .qty-btn { width: 44px; height: 44px; }
  .cart-remove { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .qty-btn, .cart-remove { transition: none; }
  .qty-btn:active, .cart-remove:active { transform: none; }
}

/* --- Cart toast: move out of the header's way on phones ------------------- */
@media (max-width: 575.98px) {
  .cart-toaster {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: .75rem !important;
    padding-bottom: max(.75rem, env(safe-area-inset-bottom)) !important;
  }
  .cart-toaster .toast { width: 100%; }
}
