/* ============================================================
   Concursos — estilos globales
   ============================================================ */
:root {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.92);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-2: #8b5cf6;
  --danger: #ef4444;
  --ok: #10b981;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Fondo dinámico por concurso (injected inline por la app) */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Overlay oscuro fijo (sin blur) para legibilidad del texto.
     El desenfoque se aplica a las tarjetas .card, no a la página. */
  background: linear-gradient(180deg,
    rgba(2, 6, 23, 0.55) 0%,
    rgba(2, 6, 23, 0.35) 45%,
    rgba(2, 6, 23, 0.55) 100%);
}

/* Overlay oscuro para legibilidad */
.page > * { position: relative; z-index: 1; }

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---------------------------------------------------------- Header */
header.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 28px;
}
header.top .brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
header.top nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 18px;
  font-size: 0.95rem;
}
header.top nav a:hover { color: var(--text); }

/* ---------------------------------------------------------- Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
/* Desenfoque local: solo dentro de las tarjetas. El texto se renderiza
   sobre el elemento .card, por lo que NO se aplica blur al texto. */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(15, 23, 42, 0.25);
  pointer-events: none;
}
.card > * { position: relative; }
.card { position: relative; }

.card h2 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

/* Grid de tarjetas (concursos / proyectos) */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: 20px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.tile:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.2);
}
.tile .title {
  font-size: 1.1rem;
  font-weight: 600;
}
.tile .desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  flex: 1;
}
.tile .meta {
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  gap: 14px;
  margin-top: 6px;
}
.tile .tile-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

/* ---------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
}
.btn.ghost:hover { background: rgba(255,255,255,0.06); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #dc2626; }
.btn.small { padding: 5px 10px; font-size: 0.82rem; }
.btn.success { background: var(--ok); }
.btn.success:hover { background: #059669; }

/* ---------------------------------------------------------- Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
/* Selects: fondo sólido oscuro para que el texto se lea tanto en
   fondos claros como oscuros de la página (y el desplegable del SO
   no herede colores del tema). */
.field select {
  background: #1e293b;
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.18);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.field select option {
  background: #1e293b;
  color: #f1f5f9;
  padding: 8px 10px;
}
.field select option:checked {
  background: #334155;
  color: #ffffff;
}
.field select:focus {
  background: #243449;
  border-color: var(--accent);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field .hint {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------------------------------------------------------- Color palette picker */
.type-seg { display: flex; gap: 6px; margin-top: 4px; }
.type-seg label {
  position: relative;
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.type-seg label:hover { background: rgba(255, 255, 255, 0.08); }
.type-seg input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.type-seg input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.type-seg .type-seg-label {
  display: block;
  padding: 6px 0;
  border-radius: 7px;
  transition: background 0.12s ease;
}
.type-seg input:checked + .type-seg-label {
  background: var(--accent);
  color: #fff;
}
.type-seg-label {
  border: 1px solid var(--panel-border);
}
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; margin-top: 4px; }
.swatch {
  position: relative;
  height: 46px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.swatch:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.35); }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.swatch input:checked + .swatch-box { outline: 3px solid #fff; outline-offset: 2px; }
.swatch .swatch-box {
  position: absolute; inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,0.25);
}
.swatch .swatch-label {
  position: relative; z-index: 1;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  pointer-events: none;
}
.swatch.swatch-textured .swatch-label { display: none; }
.color-preview {
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.color-preview.empty { color: var(--muted); opacity: 0.7; }
.color-preview.preview-color { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.55); }

/* ---------------------------------------------------------- Alertas */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert.error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239,68,68,0.4); }
.alert.ok    { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16,185,129,0.4); }

/* ---------------------------------------------------------- Efectos JS (pantalla de votación) */
.effect-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  display: block;
}

/* ---------------------------------------------------------- Footer */
footer {
  margin-top: 40px;
  padding: 18px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--panel-border);
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }

/* ---------------------------------------------------------- Efecto en la votación (admin) */
.fx-stage {
  position: relative;
  width: 100%;
  height: 150px;
  border-radius: 8px;
  background: linear-gradient(160deg, #0b1020, #1b1233);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  margin-bottom: 12px;
}
.fx-stage canvas { position: absolute; inset: 0; }
.fx-stage-label {
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.3px;
  pointer-events: none;
  z-index: 1;
}

/* ---------------------------------------------------------- Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge.open { background: rgba(16,185,129,0.2); color: var(--ok); }
.badge.closed { background: rgba(239,68,68,0.2); color: var(--danger); }

/* ---------------------------------------------------------- Proyecto */
.project-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 720px) {
  .project-hero { grid-template-columns: 1fr; }
}
.vote-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.vote-form .btn { width: 100%; padding: 12px; }
.votes-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}