/* Paleta de gironanetaidigna.cat */

:root {
  --blue: #0f5278;
  --blue-dark: #083a57;
  --sky: #86d2e1;
  --sky-soft: #e8f8fb;
  --green: #5dbb63;
  --green-dark: #3f9445;
  --green-soft: #edf8ee;
  --dark: #102c3d;
  --text: #2d3b43;
  --muted: #647780;
  --white: #ffffff;
  --soft: #f6fbfc;
  --border: #d7e9ee;
  --shadow: 0 22px 70px rgba(16, 44, 61, .13);
  --shadow-sm: 0 6px 20px rgba(16, 44, 61, .08);

  --warn: #b8791b;
  --warn-soft: #fdf3e2;
  --danger: #c0392b;
  --danger-soft: #fdeceb;

  --radi: 20px;
  --radi-sm: 12px;
  --radi-pill: 999px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;

  --amplada: 1180px;
  --amplada-estreta: 620px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--soft);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--dark); line-height: 1.2; margin: 0 0 .6em; font-weight: 800; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.3rem, 3.5vw, 1.75rem); letter-spacing: -.01em; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1rem; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }

img { max-width: 100%; height: auto; display: block; }

/* Estructura */

.contenidor {
  width: 100%;
  max-width: var(--amplada);
  margin: 0 auto;
  padding: 0 20px;
}

.contenidor-estret { max-width: var(--amplada-estreta); }

main { padding: 28px 0 64px; }

.pila > * + * { margin-top: 1rem; }
.pila-gran > * + * { margin-top: 1.75rem; }

/* Capcalera */

.capcalera {
  position: sticky;
  top: 0;
  z-index: 500;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.capcalera-int {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 66px;
}

.marca {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--blue);
  text-decoration: none;
  font-size: 1.05rem;
}
.marca img { width: 34px; height: 34px; }
.marca span { line-height: 1.15; }
.marca small { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); }

.menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.menu a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: .94rem;
  padding: 8px 12px;
  border-radius: var(--radi-pill);
}
.menu a:hover { color: var(--blue); background: var(--sky-soft); }
.menu a.actiu { color: var(--blue); }

/* En mobil el menu textual passa a una barra inferior fixa */
.menu-mobil { display: none; }

/* Botons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border: 1px solid transparent;
  border-radius: var(--radi-pill);
  background: var(--blue);
  color: var(--white);
  font: inherit;
  font-weight: 700;
  font-size: .97rem;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, transform .05s, box-shadow .15s;
  /* Objectiu tactil comode al mobil */
  min-height: 48px;
}
.btn:hover { background: var(--blue-dark); color: var(--white); }
/* Els botons dins del menu no han d'heretar el color de .menu a */
.menu a.btn, .menu a.btn:hover, .menu a.btn.actiu { color: var(--white); }
.menu a.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.btn[disabled], .btn.carregant { opacity: .6; pointer-events: none; }

.btn-verd { background: var(--green); }
.btn-verd:hover { background: var(--green-dark); }

.btn-clar {
  background: var(--white);
  color: var(--blue);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-clar:hover { background: var(--sky-soft); color: var(--blue-dark); }

.btn-perill { background: var(--danger); }
.btn-perill:hover { background: #a5301f; }

.btn-petit { padding: 8px 16px; min-height: 38px; font-size: .87rem; }
.btn-bloc { display: flex; width: 100%; }

/* Targetes */

.targeta {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radi);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.targeta-gran { padding: 32px; box-shadow: var(--shadow); }
.targeta-blava { background: var(--blue); color: #dff1f7; border-color: var(--blue); }
.targeta-blava h1, .targeta-blava h2, .targeta-blava h3 { color: var(--white); }

.graella { display: grid; gap: 18px; }
.graella-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.graella-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* Formularis */

.camp { margin-bottom: 20px; }

.camp label, .etiqueta {
  display: block;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
  font-size: .95rem;
}

.camp .ajuda {
  font-size: .84rem;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.45;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="search"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radi-sm);
  background: var(--white);
  font: inherit;
  /* 16px evita que iOS faci zoom en enfocar el camp */
  font-size: 16px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  min-height: 48px;
}

textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 4px var(--sky-soft);
}

input.error, select.error, textarea.error { border-color: var(--danger); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath fill='%23647780' d='M1.4 0 7 5.6 12.6 0 14 1.4 7 8.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 42px;
}

/* Caselles de consentiment */
.consentiment {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radi-sm);
  margin-bottom: 12px;
  cursor: pointer;
  font-size: .91rem;
  line-height: 1.5;
}
.consentiment input[type="checkbox"] {
  width: 22px; height: 22px;
  margin: 1px 0 0;
  flex: 0 0 auto;
  accent-color: var(--blue);
  cursor: pointer;
}
.consentiment:has(input:checked) { background: var(--sky-soft); border-color: var(--sky); }

/* Avisos */

.avis {
  padding: 15px 18px;
  border-radius: var(--radi-sm);
  border: 1px solid var(--border);
  background: var(--sky-soft);
  margin-bottom: 20px;
  font-size: .93rem;
  line-height: 1.55;
}
.avis p:last-child { margin-bottom: 0; }
.avis-ok     { background: var(--green-soft); border-color: #bfe3c2; color: #245c29; }
.avis-error  { background: var(--danger-soft); border-color: #f0c2bd; color: #8c2418; }
.avis-atencio{ background: var(--warn-soft); border-color: #f0dcb5; color: #7a5210; }

.llista-errors { margin: 8px 0 0; padding-left: 20px; }
.llista-errors li { margin-bottom: 4px; }

/* Etiquetes d'estat */

.etiqueta-estat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: var(--radi-pill);
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
}
.etiqueta-estat::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.estat-nova       { background: var(--sky-soft);   color: #14607f; }
.estat-revisada   { background: #eef1fb;           color: #3d4d94; }
.estat-tramesa    { background: var(--warn-soft);  color: var(--warn); }
.estat-resolta    { background: var(--green-soft); color: var(--green-dark); }
.estat-descartada { background: #eef1f2;           color: var(--muted); }
.estat-sense_resposta { background: var(--warn-soft); color: #8a6410; }

.marca-info {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radi-pill);
  background: var(--soft);
  border: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
}
.marca-reincidencia { background: var(--danger-soft); border-color: #f0c2bd; color: var(--danger); }
.marca-duplicat     { background: var(--warn-soft);   border-color: #f0dcb5; color: var(--warn); }

/* Fotos */

.fotos-zona {
  border: 2px dashed var(--border);
  border-radius: var(--radi);
  padding: 22px;
  text-align: center;
  background: var(--white);
  transition: border-color .15s, background .15s;
}
.fotos-zona:hover { border-color: var(--sky); background: var(--sky-soft); }
.fotos-botons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.fotos-previa {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.foto-mini { position: relative; aspect-ratio: 1; }
.foto-mini img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: var(--radi-sm);
  border: 1px solid var(--border);
}
.foto-mini button {
  position: absolute;
  top: 5px; right: 5px;
  width: 28px; height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(16, 44, 61, .78);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.foto-mini button:hover { background: var(--danger); }

/* Mapa */

#mapa, .mapa {
  height: 300px;
  border-radius: var(--radi-sm);
  border: 1px solid var(--border);
  z-index: 1; /* per sota de la capcalera enganxada */
}

/* Llista d'incidencies (usuari) */

.incidencia-fila {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radi-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.incidencia-fila:hover { border-color: var(--sky); box-shadow: var(--shadow-sm); color: inherit; }
.incidencia-fila .mini {
  width: 78px; height: 78px;
  flex: 0 0 auto;
  border-radius: var(--radi-sm);
  object-fit: cover;
  background: var(--soft);
}
.incidencia-fila .cos { flex: 1; min-width: 0; }
.incidencia-fila .codi { font-size: .78rem; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.incidencia-fila h3 { margin: 2px 0 4px; font-size: 1.02rem; }
.incidencia-fila .adreca {
  color: var(--muted);
  font-size: .88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Buit */

.buit {
  text-align: center;
  padding: 54px 20px;
  color: var(--muted);
}
.buit .icona { font-size: 2.6rem; margin-bottom: 10px; }

/* Peu */

.peu {
  border-top: 1px solid var(--border);
  background: var(--white);
  padding: 26px 0;
  margin-top: 40px;
  font-size: .87rem;
  color: var(--muted);
}
.peu-int { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.peu a { color: var(--muted); text-decoration: none; }
.peu a:hover { color: var(--blue); text-decoration: underline; }
.peu .dreta { margin-left: auto; display: flex; gap: 14px; }

/* Panell d'administracio */

.admin body, body.admin { background: #eef4f6; }

.admin-capcalera {
  background: var(--dark);
  color: #cfe0e8;
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 500;
}
.admin-capcalera a { color: #cfe0e8; text-decoration: none; font-weight: 600; }
.admin-capcalera a:hover { color: var(--white); }
.admin-capcalera .marca { color: var(--white); font-size: 1rem; }
.admin-capcalera .menu a { color: #a9c3ce; }
.admin-capcalera .menu a:hover, .admin-capcalera .menu a.actiu {
  color: var(--white);
  background: rgba(255, 255, 255, .1);
}

.estadistiques {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.estadistica {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radi-sm);
  padding: 16px 18px;
}
.estadistica .xifra { font-size: 1.9rem; font-weight: 800; color: var(--blue); line-height: 1.1; }
.estadistica .etiq { font-size: .82rem; color: var(--muted); font-weight: 600; }

.filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radi-sm);
  padding: 16px;
  margin-bottom: 18px;
}
.filtres .camp { margin: 0; flex: 1 1 165px; }
.filtres .camp label { font-size: .8rem; margin-bottom: 3px; }
.filtres input, .filtres select { min-height: 42px; padding: 9px 13px; font-size: .92rem; }

.taula-envolt {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radi-sm);
  overflow-x: auto;
}
table.taula { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.taula th {
  text-align: left;
  padding: 12px 14px;
  background: var(--soft);
  border-bottom: 1px solid var(--border);
  font-size: .79rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  white-space: nowrap;
}
table.taula td { padding: 12px 14px; border-bottom: 1px solid #eaf2f4; vertical-align: middle; }
table.taula tr:last-child td { border-bottom: none; }
table.taula tbody tr:hover { background: var(--soft); }
table.taula .mini { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }

.paginacio { display: flex; gap: 6px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.paginacio a, .paginacio span {
  padding: 8px 14px;
  border-radius: var(--radi-sm);
  border: 1px solid var(--border);
  background: var(--white);
  text-decoration: none;
  color: var(--blue);
  font-weight: 600;
  font-size: .9rem;
}
.paginacio .actual { background: var(--blue); color: var(--white); border-color: var(--blue); }

.detall-graella { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }

.dades-llista { margin: 0; }
.dades-llista dt {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
  margin-top: 14px;
}
.dades-llista dt:first-child { margin-top: 0; }
.dades-llista dd { margin: 2px 0 0; }

.linia-temps { list-style: none; margin: 0; padding: 0; }
.linia-temps li {
  position: relative;
  padding: 0 0 18px 22px;
  border-left: 2px solid var(--border);
  font-size: .9rem;
}
.linia-temps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.linia-temps li::before {
  content: "";
  position: absolute;
  left: -7px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--sky);
  border: 2px solid var(--white);
}
.linia-temps .quan { color: var(--muted); font-size: .8rem; }

/* Utilitats */

.text-mut { color: var(--muted); }
.text-petit { font-size: .87rem; }
.text-centre { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.75rem; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-entre { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.flex-embolica { flex-wrap: wrap; }
.amaga { display: none !important; }

.nomes-lectors {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Mobil */

@media (max-width: 780px) {
  main { padding: 20px 0 84px; }
  .contenidor { padding: 0 16px; }
  .targeta { padding: 20px; }
  .targeta-gran { padding: 22px; }
  .detall-graella { grid-template-columns: 1fr; }

  /* El menu textual desapareix i el substitueix la barra inferior */
  .capcalera .menu { display: none; }

  .menu-mobil {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 600;
    background: rgba(255, 255, 255, .98);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .menu-mobil a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    text-decoration: none;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 600;
  }
  .menu-mobil a .icona { font-size: 1.25rem; line-height: 1; }
  .menu-mobil a.actiu { color: var(--blue); }

  .peu { margin-bottom: 62px; }
  .peu-int { flex-direction: column; align-items: flex-start; }
  .peu .dreta { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Impressio */

@media print {
  .capcalera, .menu-mobil, .peu, .btn, .filtres { display: none !important; }
  body { background: #fff; }
  .targeta { box-shadow: none; border-color: #ccc; }
}
