/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-fire-dark: #b71c1c;
  --color-fire: #e53935;
  --color-fire-light: #ff7043;
  --color-amber: #ff8f00;
  --color-gold: #ffc107;
  --color-gold-light: #ffe082;
  --color-cream: #fff8e1;
  --color-tile-blue: #1565c0;
  --color-tile-blue-light: #42a5f5;
  --color-tile-pattern: #0d47a1;
  --color-white: #ffffff;
  --color-dark: #1a1a1a;
  --color-gray: #757575;
  --color-gray-light: #e0e0e0;
  --color-success: #2e7d32;
  --color-error: #c62828;

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.2);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-cream);
  color: var(--color-dark);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ===== FONDO DECORATIVO ===== */
.fire-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: var(--color-cream);
}

/* Patrón de azulejo de Manises */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.03;
  background-image:
    repeating-linear-gradient(0deg, var(--color-tile-blue) 0px, var(--color-tile-blue) 1px, transparent 1px, transparent 60px),
    repeating-linear-gradient(90deg, var(--color-tile-blue) 0px, var(--color-tile-blue) 1px, transparent 1px, transparent 60px);
}

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, var(--color-fire-dark) 0%, var(--color-fire) 40%, var(--color-amber) 100%);
  padding: 2rem 1rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 25px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 24' preserveAspectRatio='none'%3E%3Cpath fill='%23fff8e1' d='M0 24h1200V12C1100 0 1000 18 900 12S700 0 600 12 400 0 300 12 100 0 0 12z'/%3E%3Crect y='23' width='1200' height='1' fill='%23fff8e1'/%3E%3C/svg%3E") no-repeat bottom center;
  background-size: 100% 100%;
}

.header__title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  color: var(--color-white);
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
  margin-bottom: 0.5rem;
}

.header__subtitle {
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: var(--color-gold-light);
  margin-bottom: 0.3rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.header__tagline {
  font-size: clamp(0.8rem, 2vw, 0.95rem);
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 1rem;
  font-weight: 400;
}

.countdown {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.countdown__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
}

.countdown__number {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 900;
  color: var(--color-white);
  line-height: 1;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.3);
}

.countdown__label {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.countdown--ended {
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  font-weight: 700;
  color: var(--color-gold-light);
}

.header__cta {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 700;
  padding: 0.75rem 2rem;
  margin-bottom: 0.5rem;
  background: var(--color-white);
  color: var(--color-fire);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
}

.header__cta:hover {
  background: var(--color-cream);
  color: var(--color-fire-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.header__cta--hidden {
  display: none !important;
}

/* ===== NAVEGACIÓN ===== */
.nav {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 1rem 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.nav__btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.2rem;
  border: 2px solid var(--color-gray-light);
  border-radius: 50px;
  cursor: pointer;
  background: var(--color-white);
  color: var(--color-gray);
  transition: all 0.3s ease;
}

.nav__btn:hover {
  border-color: var(--color-fire-light);
  color: var(--color-fire);
  background: var(--color-white);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(229, 57, 53, 0.1);
}

.nav__btn--active {
  background: var(--color-fire);
  color: var(--color-white);
  border-color: var(--color-fire);
  box-shadow: 0 2px 12px rgba(229, 57, 53, 0.3);
}

.nav__btn--active:hover {
  background: var(--color-fire-dark);
  color: var(--color-white);
  border-color: var(--color-fire-dark);
}

/* ===== MAIN ===== */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ===== VISTAS ===== */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view--active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== CARD ===== */
.card {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.card__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--color-fire-dark);
  margin-bottom: 0.5rem;
}

.card__desc {
  color: var(--color-gray);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* ===== FORMULARIO ===== */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--color-dark);
  font-size: 0.9rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-gray-light);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--color-fire);
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

/* ===== RANKINGS CONTAINER ===== */
.rankings-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .rankings-container {
    grid-template-columns: 1fr;
  }
}

.ranking-column__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--color-tile-blue);
  margin-bottom: 0.75rem;
  text-align: center;
}

/* ===== SORTABLE LIST ===== */
.sortable-list {
  list-style: none;
  min-height: 50px;
}

.sortable-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.4rem;
  background: linear-gradient(135deg, #fff 0%, #fafafa 100%);
  border: 2px solid var(--color-gray-light);
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  font-size: 0.9rem;
}

.sortable-item:active {
  cursor: grabbing;
}

.sortable-item:hover {
  border-color: var(--color-fire-light);
  box-shadow: 0 2px 8px rgba(229, 57, 53, 0.12);
}

.sortable-item.dragging {
  opacity: 0.5;
  border-color: var(--color-fire);
  background: var(--color-gold-light);
}

.sortable-item.drag-over {
  border-color: var(--color-fire);
  border-style: dashed;
  transform: scale(1.02);
}

.sortable-item__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  background: var(--color-fire);
  color: var(--color-white);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.sortable-item__name {
  flex: 1;
  font-weight: 500;
}

.sortable-item__handle {
  color: var(--color-gray);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ===== BOTONES ===== */
.btn {
  display: block;
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-fire) 0%, var(--color-amber) 100%);
  color: var(--color-white);
  box-shadow: 0 4px 15px rgba(229, 57, 53, 0.3);
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(229, 57, 53, 0.4);
}

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

.btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== MENSAJES ===== */
.message {
  margin-top: 1rem;
  padding: 0;
  border-radius: var(--radius-sm);
  font-weight: 500;
  text-align: center;
  display: none;
}

.message--success {
  display: block;
  padding: 1rem;
  background: #e8f5e9;
  color: var(--color-success);
  border: 1px solid #a5d6a7;
}

.message--error {
  display: block;
  padding: 1rem;
  background: #ffebee;
  color: var(--color-error);
  border: 1px solid #ef9a9a;
}

/* ===== TABLAS DE RANKING ===== */
.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ranking-table th {
  background: linear-gradient(135deg, var(--color-fire-dark), var(--color-fire));
  color: var(--color-white);
  padding: 0.75rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ranking-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
  text-align: center;
  width: 50px;
}

.ranking-table th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
  text-align: center;
  width: 80px;
}

.ranking-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--color-gray-light);
}

.ranking-table td:first-child {
  text-align: center;
  font-weight: 700;
  color: var(--color-fire);
}

.ranking-table td:last-child {
  text-align: center;
  font-weight: 700;
}

.ranking-table tr:hover td {
  background: rgba(255, 193, 7, 0.08);
}

.ranking-table tr:nth-child(1) td:first-child { color: #ffc107; font-size: 1.2rem; }
.ranking-table tr:nth-child(2) td:first-child { color: #90a4ae; font-size: 1.1rem; }
.ranking-table tr:nth-child(3) td:first-child { color: #8d6e63; font-size: 1.05rem; }

/* Jury result list */
.jury-list {
  list-style: none;
}

.jury-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--color-gray-light);
}

.jury-item:last-child {
  border-bottom: none;
}

.jury-item__pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  background: var(--color-fire);
  color: var(--color-white);
}

.jury-item:nth-child(1) .jury-item__pos { background: linear-gradient(135deg, #ffc107, #ff8f00); }
.jury-item:nth-child(2) .jury-item__pos { background: linear-gradient(135deg, #90a4ae, #607d8b); }
.jury-item:nth-child(3) .jury-item__pos { background: linear-gradient(135deg, #8d6e63, #5d4037); }

.jury-item__name {
  font-weight: 500;
  font-size: 0.95rem;
}

/* ===== PLACEHOLDER ===== */
.placeholder-text {
  text-align: center;
  color: var(--color-gray);
  padding: 3rem 1rem;
  font-style: italic;
  grid-column: 1 / -1;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-gray);
  font-size: 0.85rem;
}

.footer__ig {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
}

.footer__ig:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(204, 35, 102, 0.4);
}

.footer__ig-icon {
  width: 18px;
  height: 18px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .header {
    padding: 1.5rem 0.75rem 2.5rem;
  }

  .nav__btn {
    font-size: 0.72rem;
    padding: 0.45rem 0.7rem;
  }

  .card {
    padding: 1.25rem;
  }

  .main {
    padding: 1rem 0.5rem;
  }

  .card__title {
    font-size: 1.3rem;
  }

  .sortable-item {
    font-size: 0.82rem;
    padding: 0.55rem 0.65rem;
  }

  .ranking-table {
    font-size: 0.8rem;
  }

  .ranking-table th,
  .ranking-table td {
    padding: 0.5rem 0.3rem;
  }
}
