/* ═══════════════════════════════════════════════════════
   RECLAMACIÓ COL·LECTIVA RODALIES — style.css
   ═══════════════════════════════════════════════════════ */

/* ── Fonts addicionals ── */
@font-face {
  font-family: 'Geist-Bold';
  src: url('../fonts/Geist-Bold.ttf') format('truetype');
  font-style: normal;
  font-display: swap;
}

   /* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-fons:       #f5f4f2;
  --color-targeta:    #ffffff;
  --color-text:       #1a1a1a;
  --color-text-suau:  #5a5a5a;
  --color-vora:       #e0ddd8;
  --color-error:      #c0392b;
  --color-exit:       #1e6f3e;
  --color-perill:     #922b21;
  --color-linia-bg:   #888;
  --color-linia-bg:   #888;     /* sobreescrit per JS */
  --color-linia-txt:  #fff;     /* sobreescrit per JS */
  --radi:             10px;
  --ombra:            0 2px 12px rgba(0,0,0,0.08);
  --font-principal:   'Georgia', 'Times New Roman', serif;
  --font-ui:          system-ui, -apple-system, 'Segoe UI', sans-serif;
  --transicio:        150ms ease;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--color-fons);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Capçalera ── */
#capcalera {
  background: var(--color-targeta);
  border-bottom: 1px solid var(--color-vora);
  padding: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

#capcalera-contingut {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  justify-content: center;
  max-width: 680px;
  width: 100%;
}

#linia-badge {
  background: var(--color-linia-bg);
  color: var(--color-linia-txt);
  font-family: 'Geist-Bold', sans-serif;
  font-size: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-font-smoothing: antialiased;
  width: 100px;
  height: 100px;
  max-width: 100px;
  max-height: 100px;
  text-align: center;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
  animation: panell-gir 10s ease-in-out infinite;
  transform-style: preserve-3d;
  perspective: 400px;
}

@keyframes panell-gir {
  0%   { transform: rotateY(0deg); }
  40%  { transform: rotateY(0deg); }
  60%  { transform: rotateY(360deg); }
  100% { transform: rotateY(360deg); }
}

#linia-descripcio {
  font-size: 0.95rem;
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.35;
  max-width: 520px;
}

/* ── Main & cards ── */
main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--color-targeta);
  border: 1px solid var(--color-vora);
  border-radius: var(--radi);
  box-shadow: var(--ombra);
  padding: 1.5rem;
}

.card h2 {
  font-family: var(--font-ui);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-linia-bg);
  padding-bottom: 0.5rem;
}

/* ── Secció informació ── */
#text-informatiu {
  color: var(--color-text);
  font-size: 0.95rem;
  margin-bottom: 0.85rem;
  font-weight: 500;
}

#text-informatiu #link-rgpd {
  color: rgba(0, 0, 255, 1);
  font-size: 0.88rem;
  text-decoration: underline;
  cursor: pointer;
  margin: 1rem 0 .5rem;
  display: inline-block;
  outline: none;
}

#text-informatiu #link-rgpd:focus,
#text-informatiu #link-rgpd:focus-visible {
  outline: none;
}

#text-rgpd[hidden] { display: none; }

/* Text informatiu trajecte */
.trajecte-info {
  font-size: 0.78rem;
  color: var(--color-text-suau);
  margin: 0.6rem 0 0.4rem;
  font-style: italic;
}

#text-rgpd {
  color: var(--color-text-suau);
  font-size: 0.82rem;
  margin-bottom: 1.1rem;
  line-height: 1.65;
  padding: 0.9rem 1rem;
  background: var(--color-fons);
  border-radius: 7px;
  border: 1px solid var(--color-vora);
}

#comptador-bloc {
  display: flex;
  /* align-items: baseline; */
  gap: 0.5rem;
  /* padding: 0.85rem 1.1rem; */
  padding: 0.42rem 1rem;
  background: var(--color-fons);
  border-radius: 8px;
  border: 1px solid var(--color-vora);
  align-items: center;
  justify-content: center;  
}

#comptador-num {
  /* font-family: var(--font-principal); */
  font-size: 2rem;
  font-weight: bold;
  /* color: var(--color-linia-bg); */
  line-height: 1;
}

#comptador-label {
  font-size: 0.85rem;
  color: var(--color-text-suau);
}

/* ── Secció PDF — visor PDF.js ── */
#seccio-pdf { text-align: center; }

#pdf-container { margin-top: 1rem; }

#pdfjs-visor {
  border: 1px solid var(--color-vora);
  border-radius: 8px;
  overflow: hidden;
  background: #404040;
  margin: 0 -1rem 1rem;
  padding-bottom: 1rem;
}

#pdfjs-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  background: #323232;
  flex-wrap: wrap;
  justify-content: center;
}

#pdfjs-pagina {
  font-size: 0.85rem;
  color: #ddd;
  min-width: 110px;
  text-align: center;
}


.btn-pdf {
  padding: 0.3rem 0.75rem;
  background: #555;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background var(--transicio);
}

.btn-pdf:hover  { background: #777; }
.btn-pdf:disabled { opacity: 0.4; cursor: not-allowed; }

#pdfjs-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 780px;
  object-fit: contain;
}

#pdf-fallback {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--color-text-suau);
}

#pdf-fallback a { color: var(--color-linia-bg); }

/* ── Camps de formulari ── */
.camp-grup {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.camp-grup label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.obligatori { color: var(--color-error); }

.camp-grup input[type="text"],
.camp-grup input[type="email"],
.camp-grup input[type="password"],
.camp-grup select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--color-vora);
  border-radius: 7px;
  font-size: 1rem;
  font-family: var(--font-ui);
  color: var(--color-text);
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transicio), box-shadow var(--transicio);
}

.camp-grup input:focus,
.camp-grup input.focus-actiu,
.camp-grup select:focus,
.camp-grup select.focus-actiu {
  outline: none;
  border-color: var(--color-linia-bg);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
  background: var(--color-focus-fons, #f0f4ff);
}

/* Punt 3: fletxa al select — es manté en focus */
.camp-grup select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a5a5a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-color: #fff;
  padding-right: 2.2rem;
}

.camp-grup select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a5a5a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-color: var(--color-focus-fons, #f0f4ff);
  padding-right: 2.2rem;
}

.camp-grup input.invalid { border-color: var(--color-error); }
.camp-grup input.readonly { background: var(--color-fons); color: var(--color-text-suau); cursor: not-allowed; }
.camp-grup input:disabled { background: var(--color-fons); color: var(--color-text-suau); cursor: not-allowed; }
.camp-grup select:disabled { background: var(--color-fons); color: var(--color-text-suau); cursor: not-allowed; }

/* Punt 1: cursor not-allowed al botó Repetir signatura deshabilitat */
#btn-esborrar-firma:disabled,
#btn-esborrar-firma-ex:disabled {
  cursor: not-allowed;
  color: var(--color-text-suau);
}

/* Punt 2: botó Repetir signatura habilitat → color-text; deshabilitat → gris */
#btn-esborrar-firma,
#btn-esborrar-firma-ex:not(:disabled) {
  color: var(--color-text);
}

#btn-esborrar-firma,
#btn-esborrar-firma-ex {
  font-weight: 600;
  background: transparent;
}

/* Botó portaveu — color de la línia per defecte, estil Cancel·lar quan està obert */
#btn-portaveu {
  background: var(--color-linia-bg);
  color: var(--color-linia-txt);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.82rem 1rem;
  margin-bottom: 0;
  transition: filter var(--transicio), background var(--transicio), color var(--transicio);
}

#btn-portaveu.mode-cancel {
  background: transparent;
  color: var(--color-text-suau);
  border: 1.5px solid var(--color-vora);
}

#btn-portaveu:disabled { cursor: not-allowed; filter: grayscale(0.6) opacity(0.6); }
#btn-portaveu:not(.mode-cancel):hover { filter: brightness(0.88); }
#btn-portaveu.mode-cancel:hover { background: var(--color-fons); border-color: #bbb; }

.camp-error {
  font-size: 0.8rem;
  color: var(--color-error);
  min-height: 1em;
}

/* ── Camp contrasenya amb ull ── */
.pwd-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.pwd-wrapper input {
  flex: 1;
  padding-right: 2.8rem !important;
}

.btn-ull {
  position: absolute;
  right: 0.6rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-suau);
  padding: 0.2rem;
  display: flex;
  align-items: center;
  transition: color var(--transicio);
}

.btn-ull:hover { color: var(--color-text); }
.dni-fila {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.camp-dni-inline {
  flex: 1;
  margin-bottom: 0 !important;
}

.btn-inline {
  width: auto !important;
  white-space: nowrap;
  flex-shrink: 0;
  /* Alinea el botó amb la caixa de text ignorant la label i l'error */
  margin-top: 0 !important;
  margin-bottom: 1em; /* compensa l'espai del .camp-error */
  padding: 0.65rem 1.25rem !important;
  align-self: flex-end;
}

/* ── Canvas firma ── */
#canvas-wrapper,
#canvas-wrapper-ex {
  border: 1.5px solid var(--color-vora);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
  touch-action: none;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%231a1a9a' d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E") 0 24, crosshair;
}

#canvas-wrapper.readonly-canvas,
#canvas-wrapper-ex.readonly-canvas {
  cursor: not-allowed;
  background: var(--color-fons);
  touch-action: auto;
}

#canvas-wrapper.readonly-canvas canvas,
#canvas-wrapper-ex.readonly-canvas canvas {
  pointer-events: none;
}

#canvas-firma,
#canvas-firma-ex {
  display: block;
  width: 100%;
  height: 160px;
}

.firma-botons {
  display: flex;
  justify-content: flex-end;
  /* margin-top: 0.5rem; */
  margin-top: 0;
}

/* ── Secció firma ── */
#firma-nou,
#firma-existent {
  padding-top: 1rem;
  margin-top: 1rem;
}

/* ── Botons accions ── */
.botons-accio {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

/* Evita que display:flex sobreescrigui l'atribut hidden */
.botons-accio[hidden] { display: none !important; }

.btn-principal {
  display: block;
  width: 100%;
  padding: 0.82rem 1rem;
  background: var(--color-linia-bg);
  color: var(--color-linia-txt);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: filter var(--transicio);
																   
  /* margin-top: 0.5rem; */
  margin-top: 0;
  letter-spacing: 0.02em;
  text-align: center;
}

.btn-principal:hover   { filter: brightness(0.88); }
.btn-principal:active  { filter: brightness(0.78); }
.btn-principal:disabled {
											  
  filter: grayscale(0.6) opacity(0.6);
  cursor: not-allowed;
}

.btn-perill {
  display: block;
  width: 100%;
  padding: 0.82rem 1rem;
  background: rgba(220,0,0,1);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: filter var(--transicio);
  letter-spacing: 0.02em;
}

.btn-perill:hover  { filter: brightness(0.82); }
.btn-perill:active { filter: brightness(0.68); }

/* Botons blaus: portaveu, accedir, generar */
#btn-portaveu:not(.mode-cancel),
#btn-verificar-pwd,
#btn-generar {
  background: rgba(0,0,255,1);
  color: #fff;
  border: none;
}

#btn-portaveu:not(.mode-cancel):hover,
#btn-verificar-pwd:hover,
#btn-generar:hover { filter: brightness(0.82); }

#btn-portaveu:not(.mode-cancel):active,
#btn-verificar-pwd:active,
#btn-generar:active { filter: brightness(0.68); }

.btn-secundari {
  /* padding: 0.45rem 1rem; */
  padding: 0.82rem 1rem;
  /* background: transparent; */
  background: lightgray;
  /* color: var(--color-text-suau); */
  color: var(--color-text);
  font-weight: 600;
  border: 1.5px solid var(--color-vora);
  border-radius: 7px;
  font-size: 0.88rem;
  font-family: var(--font-ui);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transicio), border-color var(--transicio);
  text-align: center;
}

.btn-secundari:hover  { background: #d0d0d0; border-color: #aaa; }
.btn-secundari:active { background: #b8b8b8; border-color: #999; }

/* Botons Cancel·lar / Tornar enrere — fons blanc, border color del text */
#btn-cancel-nou,
#btn-cancel-ex,
#btn-cancel-edicio,
#btn-cancel-portaveu,
#btn-cancel-portaveu2 {
  background: #fff;
  border-color: var(--color-text);
  color: var(--color-text);
}

#btn-cancel-nou:hover,
#btn-cancel-ex:hover,
#btn-cancel-edicio:hover,
#btn-cancel-portaveu:hover,
#btn-cancel-portaveu2:hover {
  background: #f0f0f0;
  border-color: var(--color-text);
}

#btn-cancel-nou:active,
#btn-cancel-ex:active,
#btn-cancel-edicio:active,
#btn-cancel-portaveu:active,
#btn-cancel-portaveu2:active {
  background: #e0e0e0;
  border-color: var(--color-text);
}

/* Botó portaveu inline dins firma-existent */
.btn-portaveu {
  display: block;
  width: 100%;
  padding: 0.82rem 1rem;
  background: rgba(0,0,255,1);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: filter var(--transicio);
  letter-spacing: 0.02em;
  text-align: center;
}
.btn-portaveu:hover  { filter: brightness(0.82); }
.btn-portaveu:active { filter: brightness(0.68); }

.btn-block { display: block; width: 100%; }

/* ── Missatges ── */
.missatge {
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 7px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.missatge.exit  { background: #eaf7ef; color: var(--color-exit); border: 1px solid #b7e4c7; }
.missatge.error { background: #fdf0ef; color: var(--color-error); border: 1px solid #f5c6c4; }

/* ── Portaveu ── */
.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.5;
}

.check-label input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  accent-color: var(--color-linia-bg);
  flex-shrink: 0;
  cursor: pointer;
}

#portaveu-bloc {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-vora);
				
						 
		 
}

.portaveu-benvinguda {
  font-size: 0.9rem;
  color: var(--color-exit);
  font-weight: 600;
  margin-bottom: 1rem;
  padding: 0.6rem 0.9rem;
  background: #eaf7ef;
  border-radius: 6px;
  border: 1px solid #b7e4c7;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.25rem 1rem;
  font-size: 0.78rem;
  color: var(--color-text-suau);
  border-top: 1px solid var(--color-vora);
  background: var(--color-targeta);
}

/* ── Spinner ── */
.carregant {
  display: inline-block;
			 
  width: 1em; height: 1em;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
											  
  animation: gir 0.7s linear infinite;
  margin-right: 0.5em;
  vertical-align: middle;
}

@keyframes gir { to { transform: rotate(360deg); } }
															 

/* ── Responsive ── */
@media (max-width: 480px) {
  #capcalera { padding: 1rem; }
  #capcalera-contingut { justify-content: flex-start; }
  #linia-badge { font-size: 1.1rem; min-width: 3rem; min-height: 3rem; }
  #linia-descripcio { font-size: 0.88rem; }
  .card { padding: 1.1rem; }
  #pdfjs-canvas { max-height: 520px; }
  #pdfjs-visor { margin: 0 -0.1rem; }
  #comptador-num { font-size: 1.6rem; }
  .btn-inline { width: 100% !important; }
}

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