/* ═══════════════════════════════════════════
   TRESOR PLATA 2026 — REVISIO DE CANDIDATS
   ═══════════════════════════════════════════ */

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

:root {
  --c-bg:       #0b0f14;
  --c-surface:  #10161e;
  --c-surface2: #171e28;
  --c-border:   rgba(255,255,255,0.1);
  --c-text:     #e8eef5;
  --c-muted:    #7d8fa3;
  --c-accent:   #ff6b4a;
  --c-accent-dim: rgba(255,107,74,0.18);
  --c-yes:      #34d399;
  --c-yes-dim:  rgba(52,211,153,0.15);
  --c-no:       #f87171;
  --c-no-dim:   rgba(248,113,113,0.15);
  --c-conflict: #fbbf24;
  --c-conflict-dim: rgba(251,191,36,0.15);
  --c-discard:  rgba(255,255,255,0.25);
  --c-pending:  rgba(255,255,255,0.4);
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Source Sans 3', system-ui, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --blur: blur(14px);
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  overflow: hidden;
}

.hidden { display: none !important; }

/* ═══ LOGIN ═══ */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255,107,74,0.08) 0%, transparent 70%);
}

.login-card {
  width: 340px;
  max-width: calc(100vw - 40px);
  padding: 36px 32px 28px;
  border-radius: 20px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  text-align: center;
}

.login-subtitle {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--c-muted);
  text-align: center;
}

.login-form {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c7d4e2;
}

.login-field input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: rgba(255,255,255,0.05);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-dim);
}

.login-error {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--c-no-dim);
  color: var(--c-no);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.login-btn {
  margin-top: 4px;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--c-accent), #e84a2b);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(232,74,43,0.35);
}

.login-btn:active { transform: translateY(0); }

.login-hint {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--c-muted);
  text-align: center;
}

.login-hint strong {
  color: var(--c-text);
  font-weight: 600;
}

/* ═══ APP LAYOUT ═══ */
.app {
  position: fixed;
  inset: 0;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ═══ TOP BAR ═══ */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(11,15,20,0.88);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--c-border);
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.topbar-user {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-accent);
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--c-accent-dim);
}

.topbar-stats {
  display: flex;
  gap: 16px;
  margin-left: auto;
  margin-right: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.stat-yes  { color: var(--c-yes); }
.stat-no   { color: var(--c-no); }
.stat-conflict { color: var(--c-conflict); }

.stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-muted);
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
  color: #fff;
}

.btn-review {
  background: linear-gradient(135deg, var(--c-accent), #e84a2b);
  box-shadow: 0 4px 14px rgba(232,74,43,0.3);
}

.btn-review:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(232,74,43,0.4);
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--c-border);
  padding: 8px 10px;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.14);
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  position: absolute;
  top: 52px;
  right: 0;
  bottom: 0;
  z-index: 1000;
  width: 340px;
  display: flex;
  flex-direction: column;
  background: rgba(11,15,20,0.92);
  backdrop-filter: var(--blur);
  border-left: 1px solid var(--c-border);
  transform: translateX(0);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}

.sidebar.collapsed {
  transform: translateX(100%);
}

.sidebar-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--c-border);
}

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c-muted);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.tab:hover {
  color: var(--c-text);
  background: rgba(255,255,255,0.06);
}

.tab.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.candidate-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.candidate-list::-webkit-scrollbar { width: 6px; }
.candidate-list::-webkit-scrollbar-track { background: transparent; }
.candidate-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 99px;
}

.candidate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid transparent;
}

.candidate-row:hover {
  background: rgba(255,255,255,0.06);
}

.candidate-row.selected {
  background: var(--c-accent-dim);
  border-color: rgba(255,107,74,0.3);
}

.candidate-row.discarded {
  opacity: 0.35;
  pointer-events: none;
}

.cand-indicator {
  width: 4px;
  height: 28px;
  border-radius: 99px;
  flex-shrink: 0;
}

.cand-indicator.pending  { background: var(--c-pending); }
.cand-indicator.voted-yes { background: var(--c-yes); }
.cand-indicator.voted-no  { background: var(--c-no); }
.cand-indicator.conflict  { background: var(--c-conflict); }
.cand-indicator.discarded { background: var(--c-discard); }

.cand-info {
  flex: 1;
  min-width: 0;
}

.cand-coord {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cand-meta {
  font-size: 0.7rem;
  color: var(--c-muted);
  margin-top: 1px;
}

.cand-votes {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
}

.badge-yes {
  background: var(--c-yes-dim);
  color: var(--c-yes);
}

.badge-no {
  background: var(--c-no-dim);
  color: var(--c-no);
}

/* ═══ REVIEW CARD ═══ */
.review-card {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  width: 340px;
  max-width: calc(100vw - 32px);
  border-radius: 16px;
  background: rgba(16,22,30,0.95);
  backdrop-filter: var(--blur);
  border: 1px solid var(--c-border);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  animation: cardIn 0.25s cubic-bezier(0.4,0,0.2,1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.review-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.review-coord {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.review-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
}

.review-status.st-pending {
  background: rgba(255,255,255,0.08);
  color: var(--c-muted);
}

.review-status.st-voted {
  background: rgba(255,255,255,0.08);
  color: var(--c-text);
}

.review-card-body {
  padding: 0 16px 14px;
}

.review-counts {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: var(--c-muted);
}

.review-actions {
  display: flex;
  gap: 10px;
}

.review-btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.15s;
  color: #fff;
}

.review-btn:active { transform: scale(0.97); }

.btn-yes {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 4px 16px rgba(16,185,129,0.3);
}

.btn-yes:hover {
  box-shadow: 0 6px 22px rgba(16,185,129,0.4);
}

.btn-no {
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}

.btn-no:hover {
  box-shadow: 0 6px 22px rgba(239,68,68,0.4);
}

.review-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.review-done {
  padding: 14px 16px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-muted);
}

/* ═══ LOADING ═══ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11,15,20,0.92);
  backdrop-filter: blur(6px);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem 3rem;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--c-border);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}

.loading-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

/* ═══ LEAFLET TWEAKS ═══ */
.leaflet-popup-content-wrapper {
  background: rgba(16,22,30,0.95) !important;
  backdrop-filter: blur(10px);
  border: 1px solid var(--c-border);
  border-radius: var(--radius) !important;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  color: var(--c-text);
}

.leaflet-popup-tip {
  background: rgba(16,22,30,0.95) !important;
  border: 1px solid var(--c-border);
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.4;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 700px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .topbar-stats {
    order: 3;
    width: 100%;
    justify-content: center;
    margin: 4px 0 0;
  }

  .sidebar {
    width: 100%;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 45vh;
    border-left: none;
    border-top: 1px solid var(--c-border);
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .sidebar.collapsed {
    transform: translateY(calc(100% - 0px));
  }

  .review-card {
    bottom: auto;
    top: 58px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}
