/* Botiga escolar Lestonnac · mateixa paleta i tipografia que lestonnaclleida.cat */

:root {
  --navy: #0862a1;
  --navy-dark: #065490;
  --ink: #0e1829;
  --orange: #f97316;
  --orange-dark: #ea580c;
  --gold: #c8a951;
  --cream: #f9f7f4;
  --white: #fff;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --blue-bg: #eff6ff;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, .06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--gray-800);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1; padding-bottom: 56px; }
img { max-width: 100%; display: block; }
a { color: var(--navy); }
h1, h2 { font-family: var(--font-display); font-weight: 400; color: var(--ink); line-height: 1.15; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 28px 0 18px; }
h2 { font-size: 1.4rem; margin: 0 0 14px; }
small, .muted { color: var(--gray-500); }
code { background: var(--gray-100); padding: 2px 6px; border-radius: 6px; font-size: .9em; word-break: break-all; }

.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 860px; }
.narrow-sm { max-width: 460px; padding-top: 32px; }
.center { text-align: center; }
.left { text-align: left; display: inline-block; }

/* Capçalera */
.site-header { background: var(--white); box-shadow: 0 1px 0 var(--gray-200); position: sticky; top: 0; z-index: 10; }
.topbar { background: var(--navy); color: rgba(255, 255, 255, .85); font-size: 13px; }
.topbar-inner { display: flex; gap: 22px; padding-top: 6px; padding-bottom: 6px; }
.topbar a { color: inherit; text-decoration: none; }
.topbar a:hover { color: var(--white); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 44px; height: 44px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; color: var(--navy); }
.brand-text small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.brand-tag { margin-left: 8px; padding: 3px 10px; border-radius: 999px; background: #fff3e8; color: var(--orange-dark); font-weight: 600; font-size: 13px; }
.cart-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; color: var(--ink);
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--gray-200); }
.cart-link:hover { border-color: var(--navy); color: var(--navy); }
.badge { background: var(--orange); color: var(--white); border-radius: 999px; min-width: 22px; height: 22px; display: inline-grid; place-items: center; font-size: 13px; padding: 0 6px; }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.admin-nav a, .admin-nav button { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--gray-800); font-weight: 600; font-size: 15px; }
.admin-nav a:hover, .admin-nav button:hover { background: var(--gray-100); }
.test-banner { background: #fff7cc; color: #6b5300; text-align: center; font-size: 14px; padding: 6px 16px; }

/* Portada */
.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%); color: var(--white); text-align: center; padding: 56px 0 60px; margin-bottom: 36px; }
.hero h1 { color: var(--white); margin: 6px 0 12px; font-size: clamp(2.1rem, 5vw, 3.2rem); }
.hero p { margin: 0 auto; max-width: 560px; color: rgba(255, 255, 255, .85); }
.hero-kicker { color: var(--gold) !important; font-size: .95rem; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }

/* Com a màxim 3 per fila; en pantalles estretes en caben menys. */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(230px, calc((100% - 44px) / 3)), 1fr)); gap: 22px; }
.product-card { background: var(--white); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.product-card-img { position: relative; aspect-ratio: 1; background: var(--gray-100); }
.product-card-img img { width: 100%; height: 100%; object-fit: cover; }
.product-card-body { padding: 14px 16px 18px; }
.product-card h3 { font-family: var(--font-body); font-weight: 600; font-size: 1.05rem; margin: 0 0 4px; color: var(--ink); }
.product-card.is-soldout img { opacity: .5; }
.tag { position: absolute; top: 12px; left: 12px; background: var(--ink); color: var(--white); font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.price { color: var(--navy); font-weight: 700; margin: 0; }
.price.big { font-size: 1.6rem; }
.price small { font-size: .85rem; font-weight: 400; color: var(--gray-500); }

/* Seccions */
.section-nav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.section-nav a { color: var(--white); text-decoration: none; font-weight: 600; padding: 8px 18px; border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, .5); }
.section-nav a:hover { background: var(--white); color: var(--navy); }
.shop-section { margin-bottom: 48px; scroll-margin-top: 110px; }
.section-head { margin-bottom: 18px; }
.section-head h2 { font-size: 1.8rem; margin-bottom: 4px; }
.section-head h2 a { color: inherit; text-decoration: none; }
.section-head h2 a:hover { color: var(--navy); }
.section-head p { margin: 0; color: var(--gray-600); }
.deadline { font-weight: 600; color: var(--orange-dark) !important; margin-top: 6px !important; }
.hero .deadline { color: var(--gold) !important; margin-top: 12px !important; }
.sale-limits { list-style: none; padding: 12px 16px; margin: 0 0 16px; background: #fff3e8; border-radius: 10px; color: var(--gray-800); }
.sale-limits li + li { margin-top: 4px; }
.small { font-size: 14px; }

/* Fitxa de producte */
.breadcrumb { margin: 22px 0 0; font-size: 15px; }
.breadcrumb a { text-decoration: none; }
.product-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 18px; }
.product-photo { background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); align-self: start; }
.product-photo img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.product-info h1 { margin-top: 0; }
.description { margin: 16px 0; color: var(--gray-600); }
.buy-form fieldset { border: 0; padding: 0; margin: 18px 0; }
.buy-form legend { font-weight: 600; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 8px 14px; border: 1.5px solid var(--gray-300); border-radius: 10px; background: var(--white); cursor: pointer; font-weight: 600; font-size: 15px; }
.chip input:checked + span { border-color: var(--navy); background: var(--navy); color: var(--white); }
.chip input:focus-visible + span { outline: 3px solid rgba(8, 98, 161, .3); }
.chip.is-disabled span { color: var(--gray-500); text-decoration: line-through; cursor: not-allowed; background: var(--gray-100); }
.buy-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.qty { display: flex; flex-direction: column; font-weight: 600; font-size: 15px; gap: 4px; }
.qty input { width: 88px; }
.pickup-note { margin-top: 22px; padding: 12px 16px; background: var(--white); border-left: 4px solid var(--gold); border-radius: 8px; color: var(--gray-600); font-size: 15px; }

/* Botons i formularis */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1.5px solid var(--gray-300);
  background: var(--white); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); color: var(--white); }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-sm { padding: 5px 10px; font-size: 14px; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); cursor: pointer; }
.danger, button.link.danger { color: var(--red); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1.5px solid var(--gray-300); border-radius: 10px; background: var(--white); color: var(--gray-800);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(8, 98, 161, .15); }
.input-sm { width: 100px !important; }
.input-md { max-width: 260px; }
.subhead { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--gray-200); }
.form h2 + .muted { margin-top: -6px; }
fieldset.student { border: 1.5px solid var(--gray-200); border-radius: 10px; padding: 14px 16px 2px; margin: 0 0 14px; }
fieldset.student legend { font-weight: 700; padding: 0 6px; }
.js-add-student { margin-bottom: 18px; }
.export-links { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--gray-600); }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; margin-bottom: 16px; }
.form label small { font-weight: 400; }
.form label.check, label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
label.check input { margin-top: 5px; width: 18px; height: 18px; flex: none; }
.form label.inline { flex-direction: row; align-items: center; gap: 10px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 200px; }
.row > label.check, .row > label.inline { flex: 0 1 auto; }
.radio-group { border: 0; padding: 0; margin: 0 0 12px; }

.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 22px; }
.alert { padding: 12px 16px; border-radius: 10px; margin: 16px 0; }
.alert-ok { background: var(--green-bg); color: #065f46; }
.alert-error { background: var(--red-bg); color: #991b1b; }
.alert-info { background: var(--blue-bg); color: #1e3a8a; }
.empty { text-align: center; padding: 56px 16px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Cistella i comanda */
.cart-lines { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.cart-line { display: grid; grid-template-columns: 64px 1fr 80px 100px 32px; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--gray-100); }
.cart-line:last-child { border-bottom: 0; }
.cart-line img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--gray-100); }
.cart-line-info { display: flex; flex-direction: column; }
.cart-line-info a { text-decoration: none; color: var(--ink); }
.cart-subtotal { text-align: right; font-weight: 600; }
.cart-actions, .cart-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.cart-total { font-size: 1.2rem; margin: 0; }
.cart-footer { margin-top: 28px; }

.checkout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 15px; }
.summary-line small { display: block; }
.summary-line.total { font-weight: 700; font-size: 1.1rem; border-bottom: 0; margin-bottom: 10px; }
.pickup-box { background: var(--cream); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.pickup-box p { margin: 4px 0 0; color: var(--gray-600); font-size: 15px; }
.secure-note { font-size: 14px; color: var(--gray-500); margin-bottom: 0; }

.result-icon { width: 72px; height: 72px; border-radius: 50%; margin: 36px auto 0; display: grid; place-items: center; font-size: 34px; background: var(--gray-200); color: var(--gray-600); }
.result-icon.ok { background: var(--green-bg); color: var(--green); }
.result-icon.ko { background: var(--red-bg); color: var(--red); }

.prose h2 { font-size: 1.25rem; margin-top: 28px; }
.prose p { color: var(--gray-600); }

/* Peu */
.site-footer { background: var(--ink); color: rgba(255, 255, 255, .7); font-size: 14px; padding: 26px 0; }
.footer-inner { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.site-footer strong { color: var(--white); }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.site-footer a { color: inherit; }

/* Admin */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 24px 0; }
.stat { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; color: var(--gray-500); text-decoration: none; }
.stat span { display: block; font-family: var(--font-display); font-size: 2rem; color: var(--navy); }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.two-cols > .card { margin-bottom: 22px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); padding: 8px 10px; border-bottom: 1px solid var(--gray-200); }
.table td { padding: 10px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tr.is-muted { opacity: .55; }
.table .actions { display: flex; gap: 14px; align-items: center; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--gray-100); }
.items-cell { font-size: 14px; }
.variants-table input[type=text] { min-width: 120px; }
.preview { width: 100%; max-width: 260px; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--gray-100); margin-bottom: 14px; }
.generator { margin-top: 18px; background: var(--cream); border-radius: 10px; padding: 14px 16px; }
.generator summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.generator .row { margin-top: 14px; }
.generator label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form-actions { display: flex; gap: 18px; align-items: center; }
.toggle { border: 0; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--gray-200); color: var(--gray-600); }
.toggle.on { background: var(--green-bg); color: var(--green); }
.breakdown { padding: 0; }
.breakdown summary { cursor: pointer; font-weight: 600; color: var(--navy); padding: 16px 22px; }
.breakdown .table-wrap { padding: 0 22px 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 7px 14px; border-radius: 999px; text-decoration: none; color: var(--gray-600); font-weight: 600; font-size: 15px; background: var(--white); border: 1px solid var(--gray-200); }
.tabs a.active { background: var(--navy); border-color: var(--navy); color: var(--white); }
.search { display: flex; gap: 10px; margin-bottom: 18px; max-width: 520px; }
.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--gray-100); color: var(--gray-600); white-space: nowrap; }
.status-pagada { background: #fff3e8; color: var(--orange-dark); }
.status-lliurada { background: var(--green-bg); color: var(--green); }
.status-error, .status-cancellada { background: var(--red-bg); color: var(--red); }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--gray-500); }
.dl dd { margin: 0; word-break: break-word; }

@media (max-width: 820px) {
  .product-layout, .checkout, .two-cols { grid-template-columns: 1fr; gap: 22px; }
  .stats { grid-template-columns: 1fr; }
  .topbar-inner span { display: none; }
  .brand-tag { display: none; }
  .cart-line { grid-template-columns: 56px 1fr 64px; }
  .cart-line img { width: 56px; height: 56px; }
  .cart-subtotal { grid-column: 2; text-align: left; }
  .cart-line button { grid-column: 3; justify-self: end; }
}

/* Cursos permesos */
.course-picker { border: 1px solid var(--gray-300); border-radius: 8px; padding: 12px 14px; margin: 4px 0 0; }
.course-picker legend { font-weight: 600; padding: 0 6px; }
.course-picker p { margin: 0 0 8px; }
.course-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--gray-200); }
.course-row:first-of-type { border-top: 0; }
.course-stage { min-width: 120px; font-weight: 600; font-size: .95em; }
.course-options { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.mini-check { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px; font-weight: 400; min-height: 32px; margin: 0 !important; }
.mini-check input { width: auto; margin: 0; }
.course-note { font-weight: 600; color: var(--navy-dark); }

/* Alumnes a la fitxa del producte i a la cistella */
.buy-title { font-size: 1.15rem; margin: 18px 0 4px; }
.students-box { margin: 8px 0 4px; }
.students-box .js-add-student { margin-bottom: 8px; }
.cart-students { list-style: none; margin: 6px 0 2px; padding: 0; font-size: .92em; }
.cart-students li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 2px 0; }
.cart-qty-fixed { font-weight: 600; text-align: center; }
.summary-student { display: block; color: var(--gray-600); }

/* Properament disponible */
.tag-soon { background: var(--navy); }
.soon-note { font-weight: 600; color: var(--navy-dark); margin-top: 6px; }
.alert-soon { background: var(--blue-bg); border: 1px solid var(--navy); color: var(--navy-dark); font-weight: 600; }

/* Portada: targetes de secció, com a màxim 3 per fila */
.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(260px, calc((100% - 48px) / 3)), 1fr)); gap: 24px; margin-bottom: 48px; }
.section-card { display: flex; flex-direction: column; background: var(--white); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.section-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.section-card:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.section-card-img { position: relative; aspect-ratio: 4 / 3; background: var(--gray-100); }
.section-card-img img { width: 100%; height: 100%; object-fit: cover; }
.section-card-body { display: flex; flex-direction: column; flex: 1; padding: 16px 18px 18px; }
.section-card h3 { font-size: 1.45rem; margin: 0 0 6px; color: var(--ink); }
.section-card-text { margin: 0; color: var(--gray-600); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.section-card .deadline, .section-card .soon-note { font-size: .95rem; margin: 8px 0 0 !important; }
.section-card-more { margin-top: auto; padding-top: 14px; font-weight: 600; color: var(--navy); }
.section-card:hover .section-card-more { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .section-card, .product-card { transition: none; } .section-card:hover, .product-card:hover { transform: none; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Admin: alumnes repetits i edició d'alumnes */
.suspicious { border-left: 4px solid var(--orange); margin-bottom: 24px; }
.suspicious ul { margin: 8px 0 0; padding-left: 20px; }
.suspicious li { margin: 4px 0; }
.students-edit input[type="text"], .students-edit select { min-width: 90px; width: 100%; }

/* Admin: comandes per secció */
.section-summary { margin-bottom: 24px; }
.section-summary h2 { margin-top: 0; }
.section-tabs { margin-bottom: 10px; }
.section-tabs a.active { background: var(--ink); border-color: var(--ink); }
.breakdown-section th { background: var(--gray-100); color: var(--ink); text-align: left; }
.search-hint { margin: -6px 0 14px; }

/* Admin: correus */
.resend-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--gray-200); }
.mail-table small { color: var(--red); }
.mail-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }

/* Places esgotades amb llista d'espera */
.alert-soldout { background: var(--blue-bg); border: 1px solid var(--navy); color: var(--navy-dark); font-weight: 600; }
.alert-soldout a { color: inherit; text-decoration: underline; white-space: nowrap; }
