html {
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
}

body {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  padding: 0;
  margin: 0;
  background: #f5f6fa;
  color: #1d1d1f;
  padding-bottom: 70px; /* deja sitio para la nav inferior fija */
}

h1, h2, h3 {
  font-weight: 700;
}

button {
  border-radius: 0px !important;
}

/* ---------- Panini header ---------- */

.panini-header {
  background: #fff;
  padding: 30px 20px 20px;
  border-bottom: 4px solid #003a87;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
}

.panini-logo {
  height: 50px;
  width: auto;
  margin-bottom: 10px;
}

.panini-title {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 2px;
  margin: 0;
  text-transform: uppercase;
  color: #003a87;
}

/* ---------- Page intro ---------- */

.page-title {
  font-size: 1.6rem;
  margin-bottom: 5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-count {
  background: #003a87;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 14px;
  letter-spacing: 0.5px;
  font-family: 'Courier New', monospace;
}

.page-subtitle {
  color: #666;
  margin-bottom: 0;
}

/* ---------- Country block ---------- */

.country-block {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  margin-bottom: 25px;
  overflow: hidden;
}

.country-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #003a87;
  color: #fff;
}

.country-title {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.country-flag {
  font-size: 1.5rem;
  line-height: 1;
}

.country-code {
  color: rgba(255,255,255,.6);
  font-weight: 400;
  font-size: 0.85rem;
}

.country-progress {
  background: rgba(255,255,255,.15);
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ---------- Cromo grid (cards) ---------- */

.cromo-grid {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (min-width: 992px) {
  .cromo-grid {
      grid-template-columns: repeat(4, 1fr);
      gap: 12px;
      padding: 16px;
  }
}

@media (min-width: 1200px) {
  .cromo-grid {
      grid-template-columns: repeat(6, 1fr);
  }
}

.cromo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  padding: 8px;
  margin: 0;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s, background .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
}

.cromo-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cromo-card:hover {
  border-color: #003a87;
}

.cromo-card.selected {
  background: #003a87;
  border-color: #003a87;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,58,135,.25);
  transform: translateY(-1px);
}

/* Imagen del cromo: ratio ~73/100 igual que el cromo físico */
.cromo-card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 73 / 100;
  background: #f0f1f5;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cromo-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Placeholder cuando aún no hay imagen descargada */
.cromo-card-image-placeholder {
  font-size: 2.4rem;
  line-height: 1;
  opacity: 0.5;
}

/* Cuando el cromo está pendiente (vista por defecto) lo mostramos en escala de grises */
.cromo-card .cromo-card-image img {
  transition: filter .15s;
}

.cromo-card.selected .cromo-card-image img {
  filter: grayscale(0) opacity(1);
}

.cromo-card-number {
  font-weight: 800;
  color: #003a87;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  font-family: 'Courier New', monospace;
  margin-bottom: 2px;
}

.cromo-card-name {
  font-size: 0.72rem;
  color: #444;
  line-height: 1.2;
  word-break: break-word;
}

.cromo-card.selected .cromo-card-number,
.cromo-card.selected .cromo-card-name {
  color: #fff;
}

/* En "Mis cromos" la imagen ya se muestra en color (porque el usuario lo tiene) */
.cromo-grid.owned .cromo-card .cromo-card-image img {
  filter: none;
}

/* Página "Mis cromos": acento verde en el número */
.cromo-grid.owned .cromo-card .cromo-card-number {
  color: #1f8a3a;
}

.cromo-grid.owned .cromo-card.selected {
  background: #1f8a3a;
  border-color: #1f8a3a;
  box-shadow: 0 4px 10px rgba(31,138,58,.25);
}

.cromo-grid.owned .cromo-card.selected .cromo-card-number {
  color: #fff;
}

/* ---------- Barra flotante de acciones ---------- */

.form-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: -150px; /* justo encima de la nav inferior */
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 14px rgba(0,0,0,.08);
  transition: transform .25s ease;
  z-index: 100;
  margin: 0;
}

.form-actions > div{
  justify-content: center;
  padding: 10px 16px;
  display: flex;
  gap: 10px;
}

.form-actions.visible {
  bottom: 0px;
}

.form-actions .btn {
  flex: 1;
  max-width: 200px;
  padding: 12px 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.85rem;
}

.selection-count {
  /*
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  */
  background: #003a87;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 5px 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
}

/* ---------- Nav inferior fija ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 6px rgba(0,0,0,.05);
  z-index: 90;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 16px 8px 14px;
  color: #777;
  text-decoration: none;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.78rem;
  border-top: 3px solid transparent;
  transition: color .15s, border-color .15s;
}

.bottom-nav a.active {
  color: #003a87;
  border-top-color: #003a87;
}

/* ---------- Botones flotantes (FAB) ---------- */

.fab-stack {
  position: fixed;
  right: 16px;
  bottom: 74px; /* por encima de la bottom-nav (52px) + un poco de aire */
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 95;
}

.fab {
  width: 46px;
  height: 46px;
  border-radius: 50% !important;
  border: none;
  background: #003a87;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, background .15s, opacity .2s, visibility .2s;
  padding: 0;
}

.fab:hover {
  background: #002b66;
  transform: translateY(-1px);
}

.fab svg {
  width: 22px;
  height: 22px;
}

/* El botón "subir arriba" solo aparece tras hacer scroll */
.fab-top {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.fab-stack.scrolled .fab-top {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Si la barra de acciones está visible, ocultamos los FAB para no estorbar */
body.actions-open .fab-stack {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Drawer del índice de países ---------- */

.index-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  opacity: 0;
  transition: opacity .22s ease;
}

.index-backdrop.visible {
  opacity: 1;
}

.index-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 90vw;
  height: 100%;
  background: #fff;
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
  box-shadow: -4px 0 18px rgba(0,0,0,.18);
}

.index-drawer.open {
  transform: translateX(0);
}

.index-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #003a87;
  color: #fff;
}

.index-drawer-header h3 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.index-close {
  background: transparent;
  border: none;
  color: #fff;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.index-close svg {
  width: 22px;
  height: 22px;
}

.index-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.index-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  text-decoration: none;
  color: #1d1d1f;
  border-bottom: 1px solid #eef0f4;
  transition: background .15s;
}

.index-item:hover {
  background: #f3f5fa;
  color: #003a87;
  text-decoration: none;
}

.index-flag {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.index-name {
  flex: 1;
  font-weight: 700;
  font-size: 0.9rem;
}

.index-count {
  background: #003a87;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 11px;
  font-family: 'Courier New', monospace;
  min-width: 32px;
  text-align: center;
}

/* Variante verde para "Mis cromos" */
body.page-owned .index-count,
body.page-owned .fab {
  background: #1f8a3a;
}
body.page-owned .fab:hover {
  background: #166b2c;
}
body.page-owned .index-drawer-header {
  background: #1f8a3a;
}
body.page-owned .index-item:hover {
  color: #1f8a3a;
}

/* ---------- Responsive ---------- */

@media (max-width: 576px) {
  .country-header {
      align-items: flex-start;
      gap: 6px;
      padding: 12px 14px;
  }
  .panini-header {
      padding: 22px 16px 16px;
  }
  .panini-title {
      font-size: 1.6rem;
  }
  .panini-logo {
      max-height: 56px;
  }
  .page-title {
      font-size: 1.3rem;
  }
}
