/* ─── Variables ───────────────────────────────────────────── */
:root {
  --bg:             #f0f4f8;
  --surface:        #ffffff;
  --surface-alt:    #f8fafc;
  --ink:            #0f172a;
  --ink-muted:      #64748b;
  --border:         #e2e8f0;
  --border-strong:  #cbd5e1;
  --primary:        #1d6fb8;
  --primary-hover:  #155e9e;
  --primary-light:  #dbeafe;
  --primary-subtle: #eff6ff;
  --badge-bg:       #e0f2fe;
  --badge-text:     #0369a1;
  --badge-border:   #bae6fd;
  --warn-bg:        #fff7ed;
  --warn-border:    #fed7aa;
  --warn-text:      #9a3412;
  --th-bg:          #e8f0fe;
  --th-text:        #1e3a5f;
  --tr-hover:       #f5f8ff;
  --shadow-xs:      0 1px 3px rgba(0,0,0,.07);
  --shadow-sm:      0 2px 8px rgba(0,0,0,.08);
  --shadow:         0 4px 16px rgba(0,0,0,.09);
  --shadow-lg:      0 8px 30px rgba(0,0,0,.11);
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --layout-width:   980px;
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 90%; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  /* Peu enganxat a baix: el cos ocupa tota la finestra i el contingut
     empeny el peu cap al fons, igual a totes les vistes. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.wide { --layout-width: 1200px; }

/* ─── Layout ──────────────────────────────────────────────── */
.wrap { max-width: var(--layout-width); margin: 0 auto; }

.page-body {
  padding: 1.75rem 1.5rem;
  flex: 1 0 auto;
}

/* Vistes amb accessos directes: centrar el bloc verticalment dins de la
   finestra. El margin:auto centra quan sobra espai i no retalla quan el
   contingut és més alt que la finestra (la pàgina llavors fa scroll). */
body.vcenter .page-body { display: flex; flex-direction: column; }
body.vcenter .page-body > .wrap { margin: auto; }

.page-head {
  max-width: var(--layout-width);
  margin: 0 auto 1rem;
  display: block;
  text-align: center;
}
.page-head h1 { margin: 0; font-size: 1.85rem; line-height: 1.2; }
.page-head p.sub { margin: .25rem 0 0; color: var(--ink-muted); }

/* Títol+subtítol dins del .grid, alineats amb el text dels botons */
.hub-head {
  text-align: left;
  padding: .4rem 1.1rem .6rem;
}
.hub-head h1 { margin: 0; font-size: 1.85rem; line-height: 1.2; }
.hub-head p.sub { margin: .25rem 0 0; color: var(--ink-muted); }
.page-head .back {
  display: inline-flex; align-items: center; gap: .3rem;
  margin-bottom: .4rem;
  text-decoration: none; color: var(--primary);
  font-size: .83rem; font-weight: 600;
  transition: color .15s;
}
.page-head .back:hover { color: var(--primary-hover); text-decoration: underline; }

.page-foot {
  padding: 1.5rem 1.5rem 2rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
}

.legal-footer {
  max-width: var(--layout-width);
  margin: 0 auto;
  font-size: .82rem;
  color: var(--ink-muted);
  text-align: center;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}
.legal-footer a { color: var(--ink-muted); text-decoration: none; }
.legal-footer a:hover { color: var(--primary); text-decoration: underline; }
.legal-footer .sep { color: var(--border-strong); }

.cookie-banner {
  position: fixed; bottom: 16px; left: 16px; right: 16px;
  max-width: 720px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .9rem 1.1rem; z-index: 1000;
}
.cookie-banner-inner { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.cookie-banner p { margin: 0; flex: 1; min-width: 240px; font-size: .88rem;
                   color: var(--ink); line-height: 1.45; }
.cookie-banner a { color: var(--primary); font-weight: 600; }
.cookie-banner button { background: var(--primary); color: white; border: none;
                        padding: .6rem 1.2rem; border-radius: var(--radius-sm);
                        font-size: .9rem; font-weight: 600; cursor: pointer; }
.cookie-banner button:hover { background: var(--primary-hover); }

.card { position: relative; }
.card .premium {
  position: absolute; top: 10px; right: 10px;
  background: #fef3c7; color: #92400e;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
}

/* ─── Header ──────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.logo-title, header img.logo-title { width: 110px; height: auto; }

h1 { margin: 0; font-size: 1.85rem; line-height: 1.2; }

/* ─── Back link ───────────────────────────────────────────── */
.back {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-bottom: .4rem;
  text-decoration: none;
  color: var(--primary);
  font-size: .83rem;
  font-weight: 600;
  letter-spacing: .01em;
  transition: color .15s;
}
.back:hover { color: var(--primary-hover); text-decoration: underline; }

/* ─── Info box ────────────────────────────────────────────── */
.info-box {
  margin-top: .7rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: .8rem 1.1rem;
  color: var(--warn-text);
  font-size: .88rem;
  line-height: 1.55;
  text-align: justify;
  box-shadow: var(--shadow-xs);
}

/* ─── Filter form ─────────────────────────────────────────── */
form.filters,
form[method="get"] {
  margin-top: .85rem;
  margin-bottom: .85rem;
  background: var(--surface);
  padding: .8rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  font-size: .85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}

form.filters label,
form[method="get"] label {
  display: flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .02em;
}

form.filters select,
form[method="get"] select {
  padding: .3rem .45rem;
  font-family: var(--font);
  font-size: .85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  min-width: 90px;
}

form.filters select:focus,
form[method="get"] select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,111,184,.12);
}

/* ─── Submit button ───────────────────────────────────────── */
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .38rem .9rem;
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-xs);
  transition: background .15s, box-shadow .15s, transform .08s;
  white-space: nowrap;
}

button[type="submit"]:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* ─── Actions bar ─────────────────────────────────────────── */
.actions {
  display: flex;
  gap: .4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: .55rem;
}

.actions a,
.actions button {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .35rem .75rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 700;
  transition: background .12s, box-shadow .12s, transform .08s;
  white-space: nowrap;
}

.actions a:hover,
.actions button:hover {
  background: var(--primary-subtle);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}

/* ─── Counter ─────────────────────────────────────────────── */
.counter {
  margin: .45rem 0;
  font-size: .82rem;
  color: var(--ink-muted);
}

/* ─── Table ───────────────────────────────────────────────── */
.table-wrap {
  margin-top: .6rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .83rem;
  background: var(--surface);
}

th, td {
  padding: 5px 8px;
  text-align: left;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--th-bg);
  color: var(--th-text);
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}

thead tr:first-child th { border-top: none; }
tbody tr:first-child td { border-top: none; }
tr td:first-child, tr th:first-child { border-left: none; }
tr td:last-child,  tr th:last-child  { border-right: none; }
tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--tr-hover); }

/* ─── Pagination ──────────────────────────────────────────── */
.paginacio {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .85rem;
  font-size: .83rem;
  color: var(--ink-muted);
  flex-wrap: wrap;
}

.paginacio a {
  display: inline-block;
  padding: .25rem .6rem;
  text-decoration: none;
  color: var(--primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: background .12s, border-color .12s;
}

.paginacio a:hover {
  background: var(--primary-subtle);
  border-color: var(--primary-light);
}

.paginacio .actiu { font-weight: 700; color: var(--ink); }

/* ─── Vistes de llista: alçada de finestra + scroll intern a la taula ─────
   Descripció i filtres queden fixos a dalt; la taula fa scroll dins del seu
   quadre i el peu groc dels enllaços legals queda sempre visible (com a
   Espai personal). ─────────────────────────────────────────────────────── */
.list-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 250px);
  min-height: 460px;
}
.list-page > .info-box,
.list-page > form,
.list-page > .actions,
.list-page > .counter,
.list-page > .paginacio { flex: 0 0 auto; }
.list-page > .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.list-page > .table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* ─── Cards (inici / hub pages: pila vertical) ──────────── */
.grid {
  display: grid;
  grid-template-columns: max-content;
  justify-content: center;
  gap: .5rem;
  margin-top: 1rem;
}

/* ─── Inici: logo xicotet centrat verticalment, alçada lligada a la pila ── */
.inici-layout {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
}
.inici-logo {
  position: relative;
  flex-shrink: 0;
  width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Segell de la vaga, estampat a la cantonada del logo d'inici ───────── */
.inici-seal {
  position: absolute;
  top: -34px;
  left: -40px;
  width: 158px;
  height: 158px;
  transform: rotate(-13deg);
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 0 1.3px rgba(8,22,14,.85)) drop-shadow(0 1px 1px rgba(0,0,0,.4));
}
.inici-seal .seal-bg          { fill: none; stroke: #3ee784; stroke-width: 3; }
.inici-seal .seal-ring        { fill: none; stroke: #3ee784; stroke-width: 1.5; }
.inici-seal .seal-ring-inner  { fill: none; stroke: #3ee784; stroke-width: 2; }
.inici-seal text              { fill: #3ee784; font-family: 'Arial Black', Impact, sans-serif; }
.inici-seal .seal-text        { font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; dominant-baseline: central; }
.inici-seal .seal-center      { font-size: 12px; font-weight: 800; text-anchor: middle; text-transform: uppercase; letter-spacing: .3px; }

/* ─── Oferta de llançament: quadre a la dreta de la targeta Espai personal ─ */
.espai-wrap { position: relative; }
.oferta-box {
  position: absolute;
  left: calc(100% + 14px);
  top: 0;
  width: 230px;
  padding: .9rem 1rem;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: #7c2d12;
  text-align: center;
  font-size: .88rem;
  line-height: 1.45;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.oferta-box:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(180,83,9,.22); }
.oferta-box strong { display: block; font-size: 1.12rem; font-weight: 800; margin: .25rem 0; color: #b45309; }
.oferta-box .nocard { display: block; margin-top: .55rem; font-size: .8rem; font-weight: 700; }

/* Aspa roja damunt del distintiu PREMIUM (ja no es paga durant l'oferta) */
.premium-tatxat { position: relative; }
.premium-tatxat::before,
.premium-tatxat::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 132%; height: 3px;
  background: #dc2626;
  border-radius: 2px;
}
.premium-tatxat::before { transform: translate(-50%,-50%) rotate(18deg); }
.premium-tatxat::after  { transform: translate(-50%,-50%) rotate(-18deg); }

@media (max-width: 1000px) {
  .oferta-box {
    position: static;
    left: auto;
    width: auto;
    margin-top: .6rem;
  }
}

/* ─── Missatge centrat (confirmació d'alta, etc.) ──────────────────────── */
.auth-msg {
  max-width: 480px;
  margin: 2rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 2rem 1.75rem;
  text-align: center;
}
.auth-msg h2 { margin: 0 0 .8rem; font-size: 1.4rem; color: var(--ink); }
.auth-msg p { color: var(--ink-muted); line-height: 1.55; margin: .4rem 0; }
.auth-msg .em { color: var(--ink); font-weight: 700; }
.auth-msg a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-msg a:hover { text-decoration: underline; }
.inici-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
  transition: transform .12s ease, box-shadow .12s ease;
}
.inici-logo:hover img { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(0,0,0,.36); }

.inici-layout .grid { margin-top: 0; }

@media (max-width: 760px) {
  .inici-layout { flex-direction: column; align-items: center; gap: 1.5rem; }
  .inici-logo { width: 160px; }
}

a.card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .85rem 1.1rem;
  box-shadow: var(--shadow-xs);
  transition: transform .1s ease, box-shadow .1s ease, border-color .1s ease;
}

a.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #b8d4f8;
}

.card h2 { margin: .1rem 0 .2rem; font-size: 1.1rem; line-height: 1.25; }
.card p  { margin: 0; color: var(--ink-muted); font-size: .9rem; line-height: 1.3; }

.badge {
  display: inline-block;
  font-size: .8rem;
  padding: .18rem .55rem;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--badge-border);
  margin-bottom: .35rem;
  font-weight: 700;
  letter-spacing: .01em;
}

/* ─── Sub-title ───────────────────────────────────────────── */
p.sub { margin: .25rem 0 0; color: var(--ink-muted); }

/* ─── Footer / disclaimer ─────────────────────────────────── */
footer, .footer-box {
  margin-top: 2rem;
  font-size: .83rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--warn-text);
  line-height: 1.55;
  text-align: justify;
  box-shadow: var(--shadow-xs);
}

footer h2, .footer-box h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: .6rem;
  color: var(--warn-text);
  text-align: left;
  padding-bottom: .3rem;
  border-bottom: 2px solid var(--warn-border);
}

/* ─── Utility ─────────────────────────────────────────────── */
.ocult-web { display: none; }

/* ─── Select2 overrides ───────────────────────────────────── */
.select2-container--default .select2-selection--single {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  height: 29px;
  font-family: var(--font);
  font-size: .85rem;
  background: var(--surface);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--ink);
  line-height: 27px;
  padding-left: 7px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 27px;
}

.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,111,184,.12);
}

.select2-dropdown {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-family: var(--font);
  font-size: .85rem;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--primary);
}

.select2-container .select2-selection__rendered {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Print ───────────────────────────────────────────────── */
@media print {
  html { font-size: 90%; }
  body { background: #fff; margin: 0; padding: 0; }
  .sitenav,
  header .logo-title,
  .info-box,
  form[method="get"],
  form.filters,
  .actions,
  .paginacio { display: none !important; }
  .table-wrap {
    border: 1px solid #000;
    border-radius: 0;
    box-shadow: none;
  }
  table { font-size: 11px; }
  th { background: #eee !important; color: #000 !important; }
  th, td { border-color: #999; }
  tbody tr:hover td { background: none; }
}

/* ─── Site navigation bar ─────────────────────────────────── */
.sitenav {
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.sitenav-inner {
  max-width: var(--layout-width);
  margin: 0 auto;
  padding: .5rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sitenav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}
.sitenav-brand img { height: 34px; width: auto; }
.sitenav-brand span { font-size: .98rem; }

.sitenav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  line-height: 1;
  padding: .35rem .55rem;
  cursor: pointer;
  color: var(--ink);
}

.sitenav-menu {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: .12rem;
  margin-left: auto;
}

.sitenav-auth {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.sitenav-menu a {
  text-decoration: none;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: .88rem;
  padding: .4rem .6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.sitenav-menu a:hover { background: var(--primary-subtle); color: var(--primary); }
.sitenav-menu a.actiu { background: var(--primary-light); color: var(--primary-hover); }

.sitenav-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: .25rem .4rem;
}

.sitenav-user { font-size: .85rem; color: var(--ink-muted); }

.sitenav-sub {
  font-size: .73rem;
  font-weight: 700;
  padding: .12rem .55rem;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.sitenav-sub.ok { background: #ecfdf5; color: #065f46; }
.sitenav-sub.no { background: #fef3c7; color: #92400e; }

.sitenav-menu form { margin: 0; display: inline; }

.sitenav-link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: .88rem;
  font-family: var(--font);
  padding: .4rem .6rem;
}
.sitenav-link-btn:hover { color: var(--primary); }

@media (max-width: 1000px) {
  .sitenav-toggle { display: block; }
  .sitenav-inner { flex-wrap: wrap; }
  .sitenav-menu {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    margin: .45rem 0 0;
    gap: 0;
  }
  .sitenav-menu.obert { display: flex; }
  .sitenav-menu a,
  .sitenav-link-btn { width: 100%; text-align: left; padding: .65rem .5rem; }
  .sitenav-sep { display: none; }
  .sitenav-user { padding: .5rem; }
  .sitenav-auth { display: flex; flex-direction: column; width: 100%; align-items: stretch; }
}
