/* ════════════════════════════════════════════════════════════════
   BASE — sistema de diseño compartido por todas las pantallas
   Variables, reset, layout (.screen), botones, cards, formularios,
   galería, votación, ranking, modales, toast, animaciones, responsive.
   Lo exclusivo de cada pantalla vive en login.css / admin.css / participant.css
   ════════════════════════════════════════════════════════════════ */

:root {
  /* Paleta alineada amb l'App Resultats (Enric): blaus més sobris i mats */
  --bg:          #06121e;
  --bg2:         #08182a;
  --surface:     #0d2137;
  --surface2:    #102748;
  --surface3:    #163254;
  --border:      #1a3566;
  --border2:     #24477e;
  --accent:      #4b8ef5;
  --accent2:     #7bb3ff;
  --accent-glow: rgba(75,142,245,0.35);
  --text:        #e8f0ff;
  --text-muted:  #5b7aa8;
  --success:     #3ecf8e;
  --danger:      #e05252;
  --warning:     #f5a623;
  --gold:        #f5a623;
  --radius:      16px;
  --radius-sm:   10px;
  --font-display:'Bebas Neue', sans-serif;
  --font-cond:   'Barlow Condensed', sans-serif;
  --font-body:   'Barlow', sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
  --tap:         52px;
  --text-base:   16px;
}


/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  /* Deep blue radial glow like the brand image */
  background-image:
    radial-gradient(ellipse 70% 50% at 50% -10%, #0d2a6e 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 90%, #091540 0%, transparent 50%);
}

/* ── NOISE TEXTURE ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9998;
}

/* ── SCREENS ── */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ════════════════════════════════
   FORM
════════════════════════════════ */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-family: var(--font-cond);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: rgba(4,9,30,0.6);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  height: var(--tap);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px; /* 16px prevents iOS zoom */
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
}

.form-group textarea {
  height: auto;
  padding: 14px 16px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select option { background: var(--surface2); }

/* ════════════════════════════════
   BUTTONS
════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-cond);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.6px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  letter-spacing: 0.3px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #2b6fd4 100%);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 20px rgba(79,143,255,0.35);
  font-size: 16px;
  letter-spacing: 1px;
}

.btn-primary:hover { box-shadow: 0 6px 28px rgba(79,143,255,0.55); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-secondary {
  background: rgba(17,34,96,0.8);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent2); }

.btn-danger { background: rgba(240,82,82,0.15); color: var(--danger); border: 1px solid rgba(240,82,82,0.35); }
.btn-danger:hover { background: rgba(240,82,82,0.25); }

.btn-success { background: rgba(62,207,142,0.15); color: var(--success); border: 1px solid rgba(62,207,142,0.35); }

.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
.btn-full { width: 100%; }

.error-msg {
  background: rgba(240,82,82,0.1);
  border: 1px solid rgba(240,82,82,0.3);
  border-radius: 8px;
  padding: 14px;
  font-size: 14px;
  color: #ff8a8a;
  margin-top: 12px;
  display: none;
  line-height: 1.5;
}

/* ════════════════════════════════
   TOPBAR (admin y participant)
════════════════════════════════ */
.topbar {
  background: rgba(7,18,51,0.95);
  border-bottom: 1px solid var(--border2);
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.topbar-logo {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #fff, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.user-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.user-badge span { color: var(--text); font-weight: 600; }

.role-badge {
  background: rgba(79,143,255,0.15);
  border: 1px solid rgba(79,143,255,0.4);
  color: var(--accent2);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}

.role-badge.admin { background: rgba(245,166,35,0.12); border-color: rgba(245,166,35,0.35); color: var(--warning); }

/* Admin view-toggle pill */
.role-badge.admin-toggle {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.role-badge.admin-toggle:hover {
  background: rgba(245,166,35,0.25);
  border-color: rgba(245,166,35,0.65);
  transform: scale(1.05);
}
.role-badge.admin-toggle:active { transform: scale(0.97); }

/* DB Mode pill (Normal / Test) */
.db-mode-btn {
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  background: rgba(52,199,89,0.15);
  border-color: rgba(52,199,89,0.5);
  color: #34c759;
}
.db-mode-btn:hover { transform: scale(1.05); filter: brightness(1.15); }
.db-mode-btn:active { transform: scale(0.97); }

/* Segell "TEST" — estampat de goma vermell, fix a la pantalla, només en mode test.
   pointer-events:none perquè no bloquegi cap clic per sota. */
#test-stamp {
  display: none;            /* JS el posa a flex quan _dbMode === 'test' */
  position: fixed;
  bottom: 18px;
  right: 16px;
  z-index: 9998;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
  color: #ff3b30;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 3px solid #ff3b30;
  border-radius: 8px;
  background: rgba(255,59,48,0.06);
  box-shadow: 0 0 0 2px rgba(255,59,48,0.15), inset 0 0 0 2px rgba(255,59,48,0.15);
  transform: rotate(-11deg);
  opacity: 0.82;
  text-shadow: 0 1px 0 rgba(255,59,48,0.25);
}
@media (max-width: 600px) {
  #test-stamp { font-size: 16px; padding: 3px 11px; bottom: 12px; right: 10px; }
}


/* Mobile logout-X button */
.btn-logout-x {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text-muted);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s, border-color 0.2s;
}
.btn-logout-x:hover { color: var(--text); border-color: var(--text-muted); }

/* ════════════════════════════════
   MAIN CONTENT
════════════════════════════════ */
.main-content {
  flex: 1;
  padding: 20px 16px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* With bottom nav, add padding so content isn't hidden behind it */
.has-bottom-nav .main-content { padding-bottom: 80px; }

/* ════════════════════════════════
   CARDS
════════════════════════════════ */
.card {
  background: rgba(13,29,74,0.6);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.card-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--text);
  line-height: 1.2;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.5;
}

/* ════════════════════════════════
   PROGRESS BAR
════════════════════════════════ */
.progress-wrap {
  background: rgba(4,9,30,0.5);
  border-radius: 100px;
  height: 10px;
  overflow: hidden;
  margin: 10px 0;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 100px;
  transition: width 0.7s cubic-bezier(.4,0,.2,1);
  min-width: 0;
  box-shadow: 0 0 10px var(--accent-glow);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 6px;
}

/* ════════════════════════════════
   STAT GRID
════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: rgba(17,34,96,0.5);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: 2px;
  color: var(--accent2);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 600;
}

/* ════════════════════════════════
   TOGGLE
════════════════════════════════ */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-wrap:last-child { border-bottom: none; }

.toggle {
  position: relative;
  width: 54px;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(4,9,30,0.6);
  border: 1px solid var(--border2);
  border-radius: 100px;
  transition: 0.3s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--text-muted);
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: rgba(79,143,255,0.2);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::after {
  background: var(--accent);
  transform: translateX(24px);
  box-shadow: 0 0 8px var(--accent-glow);
}

.toggle-label { font-size: 15px; color: var(--text); font-weight: 500; line-height: 1.4; }

/* ════════════════════════════════
   GALLERY
════════════════════════════════ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  align-items: start;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
}

.gallery-item img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  display: block;
  background: var(--surface2);
}

.gallery-item:hover { transform: scale(1.01); }
.gallery-item.selected { border-color: var(--accent); }

.gallery-item .check-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.gallery-item.selected .check-overlay { display: flex; }

.gallery-item .participant-num {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,20,0.9));
  padding: 20px 10px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent2);
}

.gallery-actions {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}

.gallery-item:hover .gallery-actions,
.gallery-item:active .gallery-actions { opacity: 1; }

/* On touch devices, always show actions */
@media (hover: none) {
  .gallery-actions { opacity: 1; }
}

.gallery-act-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: rgba(0,0,20,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.gallery-act-btn:hover { background: var(--accent); }

/* ════════════════════════════════
   VOTING UI
════════════════════════════════ */
.voting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.vote-card {
  background: rgba(17,34,96,0.5);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.vote-card:hover { border-color: var(--border2); }
.vote-card.voted { border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }

.vote-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.vote-card-footer {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vote-card-num { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }

.vote-stars { display: flex; gap: 6px; }

.star {
  font-size: 26px;
  cursor: pointer;
  color: rgba(79,143,255,0.2);
  transition: color 0.15s, transform 0.1s, filter 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Large tap target */
  padding: 4px 2px;
}

.star:hover, .star.active {
  color: var(--accent2);
  filter: drop-shadow(0 0 4px var(--accent-glow));
}
.star:active { transform: scale(1.3); }

/* ──────────────────────────────────────────────
   AUTOSAVE: flash animation when a star is clicked
   and the vote has been saved to Supabase.
────────────────────────────────────────────── */
@keyframes starFlash {
  0%   { filter: drop-shadow(0 0 4px var(--accent-glow));  transform: scale(1);   }
  40%  { filter: drop-shadow(0 0 14px #ffd166);            transform: scale(1.4); color: #ffd166; }
  100% { filter: drop-shadow(0 0 4px var(--accent-glow));  transform: scale(1);   }
}
.star.flash {
  animation: starFlash 0.8s ease-out;
}

/* ════════════════════════════════
   RANKING
════════════════════════════════ */
.ranking-list { display: flex; flex-direction: column; gap: 10px; }

.rank-item {
  background: rgba(17,34,96,0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.rank-num {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 1px;
  min-width: 40px;
  color: var(--text-muted);
  text-align: center;
}

.rank-num.gold   { color: #f5c842; text-shadow: 0 0 12px rgba(245,200,66,0.5); }
.rank-num.silver { color: #b0b8c8; }
.rank-num.bronze { color: #c87941; }

.rank-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border2);
}

.rank-info { flex: 1; min-width: 0; }
.rank-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.rank-score { font-family: var(--font-display); font-size: 28px; color: var(--accent2); letter-spacing: 1px; }

/* Rànquing detallat per repte: fila fina amb les 3 notes per criteri */
.rank-criteria {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.rank-criteria span { white-space: nowrap; }

/* ════════════════════════════════
   UPLOAD ZONE
════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79,143,255,0.05);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  height: 100%;
  width: 100%;
  z-index: 2;
}

.upload-zone .upload-icon { font-size: 44px; margin-bottom: 10px; }
.upload-zone h3 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.upload-zone p { font-size: 13px; color: var(--text-muted); }

.upload-preview { position: relative; border-radius: var(--radius); overflow: hidden; max-width: 380px; margin: 0 auto; }
.upload-preview img { width: 100%; border-radius: var(--radius); display: block; }

.upload-preview .remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════════
   OBJECTIVE / MEMBER LISTS
════════════════════════════════ */
.objective-item {
  background: rgba(17,34,96,0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.objective-item .obj-info { flex: 1; min-width: 0; }
.objective-item .obj-title { font-weight: 600; font-size: 15px; }
.objective-item .obj-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ════════════════════════════════
   PARTICIPANT TABLE
════════════════════════════════ */
.participant-table { width: 100%; border-collapse: collapse; }

.participant-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.participant-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(80,130,255,0.08);
  font-size: 14px;
  vertical-align: middle;
}

.participant-table tr:last-child td { border-bottom: none; }

/* ════════════════════════════════
   BADGES
════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-green  { background: rgba(62,207,142,0.12); color: var(--success); border: 1px solid rgba(62,207,142,0.3); }
.badge-yellow { background: rgba(245,166,35,0.12);  color: var(--warning);  border: 1px solid rgba(245,166,35,0.3); }
.badge-red    { background: rgba(240,82,82,0.12);   color: var(--danger);   border: 1px solid rgba(240,82,82,0.3); }
.badge-gray   { background: rgba(80,130,255,0.08);  color: var(--text-muted); border: 1px solid var(--border); }

/* ════════════════════════════════
   MODAL
════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,5,20,0.8);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: #0d1d4a;
  border: 1px solid var(--border2);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px;
  width: 100%;
  max-width: 500px;
  animation: slideUp 0.3s ease;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow-y: auto;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 2px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .btn { flex: 1; }

/* ════════════════════════════════
   TOAST
════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 100px;
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(.4,0,.2,1);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.success { border-color: var(--success); color: var(--success); }
#toast.error   { border-color: var(--danger);  color: var(--danger); }
#toast.info    { border-color: var(--accent);  color: var(--accent2); }

/* ════════════════════════════════
   MISC
════════════════════════════════ */
.loader {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(79,143,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.section-title {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.divider { height: 1px; background: var(--border); margin: 20px 0; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.6; }

.multi-action-bar {
  background: rgba(17,34,96,0.5);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.multi-action-bar span { font-size: 14px; color: var(--accent2); font-weight: 500; }

.hidden { display: none !important; }

/* ════════════════════════════════
   ANIMATIONS
════════════════════════════════ */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }

/* ════════════════════════════════
   RESPONSIVE — MOBILE (≤640px)
   (las reglas de bottom-nav/nav-grid/login viven en sus css de pantalla)
════════════════════════════════ */
@media (max-width: 640px) {
  /* Main content */
  .main-content { padding: 14px 14px 80px; }

  /* Stat grid: 2 cols always */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Voting: 1 col on very small, 2 col default */
  .voting-grid { grid-template-columns: 1fr; }

  /* Gallery: 2 cols */
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Stars: bigger on mobile */
  .star { font-size: 30px; padding: 6px 3px; }

  /* Cards: less padding */
  .card { padding: 16px 14px; }

  /* Topbar: compact */
  .topbar { height: 56px; }
  .topbar-logo { font-size: 22px; }
  .user-badge { display: none; } /* hidden on mobile - name shown in badge */
  .role-badge { display: none; }

  /* Toast: above bottom nav */
  #toast { bottom: 76px; }

  /* Modal: full bottom sheet */
  .modal { border-radius: 20px 20px 0 0; }

  /* Tables: horizontal scroll */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Buttons in actions: smaller */
  .card-header .btn-sm { padding: 0 10px; font-size: 12px; }
}

/* ── TABLET (641–1024px) ── */
@media (min-width: 641px) and (max-width: 1024px) {
  .main-content { padding: 24px 20px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .voting-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .modal { border-radius: 20px; margin: 20px; max-width: 480px; align-self: center; }
  .modal-overlay { align-items: center; }
}

/* ── DESKTOP (>1024px) ── */
@media (min-width: 1025px) {
  .main-content { padding: 32px 32px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .voting-grid { grid-template-columns: repeat(3, 1fr); }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .modal { border-radius: 20px; margin: 20px; max-width: 500px; align-self: center; }
  .modal-overlay { align-items: center; }
}

/* ════════════════════════════════
   BOTÓN "VEURE FOTOS" + MOSAIC
════════════════════════════════ */
.btn-view-photos {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(79,143,255,0.4);
  white-space: nowrap;
}

.btn-view-photos:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79,143,255,0.5);
}

.btn-view-photos.active {
  background: var(--surface3);
  color: var(--text);
  box-shadow: none;
}

/* Mosaic grid hover */
.mosaic-photo {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.08);
}
.mosaic-photo:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  border-color: var(--accent);
}
.mosaic-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Fullscreen image: cursor para zoom */
#fullscreen-img.zoomable {
  cursor: zoom-in;
  touch-action: none; /* el JS gestiona pinch-zoom */
}
#fullscreen-img.zoomed {
  cursor: grab;
}

/* ════════════════════════════════
   LIGHTBOX NAVIGATION ARROWS
════════════════════════════════ */
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  font-size: 28px;
  cursor: pointer;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s;
  z-index: 10;
}

.lightbox-nav-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-50%) scale(1.05);
}

.lightbox-nav-btn.prev { left: 20px; }
.lightbox-nav-btn.next { right: 20px; }
.lightbox-counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 8px 16px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .lightbox-nav-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .lightbox-nav-btn.prev { left: 10px; }
  .lightbox-nav-btn.next { right: 10px; }
}

/* ════════════════════════════════
   WATERMARK
════════════════════════════════ */
@keyframes pv-pulse {
  0%, 100% { opacity: 0.25; }
  50%       { opacity: 0.70; }
}

.pv-watermark {
  position: fixed;
  bottom: 12px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 9999;
  pointer-events: none;
  animation: pv-pulse 3s ease-in-out infinite;
}
.pv-watermark svg {
  width: 22px;
  height: 22px;
}
.pv-watermark span {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 300;
  color: #fff;
  letter-spacing: 0.5px;
}

.pv-watermark:hover {
  opacity: 0.8;
}
