:root {
  --primary: #082055;
  --shadow: rgba(0, 0, 0, 0.08);
  --bg-page: #f5f7fb;
  --text: #1a1a1a;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg-page);
  margin: 0;
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 1.15rem;
  line-height: 1.6;
}

/* Header */
header.header {
  background: #fff;
  text-align: center;
  padding: 1.5rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.logo {
  height: auto;
  max-height: 90px;
  max-width: 260px;
  object-fit: contain;
}

/* Contenedor */
.container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

/* Card */
.card {
  background: white;
  border-radius: 14px;
  box-shadow: 0 4px 24px var(--shadow);
  padding: 2rem;
  max-width: 760px;
  width: 100%;
  transition: opacity 0.3s ease;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Título */
.title {
  color: var(--primary);
  text-align: center;
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 1.2rem;
}

/* Botón ancho */
#refresh-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  width: 100%;
  padding: 1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: background 0.3s, transform 0.1s;
}
#refresh-btn:hover {
  background: #05163a;
  transform: scale(1.02);
}

/* Tabla */
#prices-table {
  width: 100%;
  border-collapse: collapse;
}
#prices-table th, #prices-table td {
  padding: 1rem;
  text-align: left;
}
#prices-table thead {
  background: var(--primary);
  color: white;
}
#prices-table tbody tr:nth-child(even) {
  background-color: #f0f3fa;
}

/* Logos bancarios */
.bank-cell {
  display: flex;
  align-items: center;
  gap: 18px;
}
/* === Contenedor circular del logo === */
.bank-logo {
  aspect-ratio: 1 / 1;                  /* Mantiene proporción cuadrada perfecta */
  width: clamp(50px, 8vw, 70px);        /* Tamaño adaptable (50px en móvil, 70px máx.) */
  min-width: 45px;
  max-width: 80px;
  border-radius: 50%;                   /* Asegura círculo perfecto */
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;                     /* Oculta partes que sobresalgan */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;                       /* Evita que el contenedor se achique */
}

/* === Imagen dentro del logo === */
.bank-logo img {
  width: 70%;
  height: 70%;
  object-fit: contain;                  /* Mantiene proporción sin recortar */
  border-radius: 50%;
  transition: transform 0.2s ease-in-out;
}

/* Pequeña animación al pasar el cursor (solo desktop) */
@media (hover: hover) {
  .bank-logo img:hover {
    transform: scale(1.05);
  }
}

/* === Nombre y precio más grandes en general === */
.bank-name, .price-cell {
  font-weight: 800;
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
}
.price-cell {
  text-align: right;
}

/* Íconos de tendencia */
.trend-icon {
  margin-right: 10px;
  font-size: 1.4rem;
  vertical-align: middle;
  transition: transform 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}
.trend-icon i.fa-arrow-up { color: #00b050; transform: translateY(-3px); }
.trend-icon i.fa-arrow-down { color: #e74c3c; transform: translateY(3px); }
.trend-icon i.fa-minus { color: #9a9a9a; opacity: 0.7; }

/* === Loader central perfectamente centrado === */
#overlay-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;           /* Centra verticalmente todo */
  justify-content: center;       /* Centra horizontalmente todo */
  z-index: 9999;
}

#overlay-loader .overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;           /* Centra cada elemento internamente */
  justify-content: center;
  text-align: center;
  gap: 16px;                     /* Espacio entre spinner y texto */
}

/* Spinner perfectamente centrado */
.spinner-big {
  border: 6px solid #d1d1d1;
  border-top: 6px solid #082055;
  border-radius: 50%;
  width: 90px;
  height: 90px;
  display: flex;
  justify-content: center;       /* Centra internamente cualquier pseudo-elemento */
  align-items: center;
  animation: spin 1s linear infinite;
  box-sizing: border-box;        /* Evita desplazamientos por borde */
  margin: 0 auto;                /* Asegura centrado en navegadores antiguos */
}

#overlay-loader p {
  color: #082055;
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* Hora bajo la tabla */
#updated-time {
  text-align: center;
  font-size: 1rem;
  color: #333;
  font-weight: 500;
  margin-top: 1rem;
  background: #f8f9fc;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #e3e6ed;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.4rem;
  font-size: 1rem;
  color: #333;
  background: #fff;
  border-top: 1px solid #eaeaea;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
}


/* === Ajustes para móviles pequeños (≤ 480 px) === */
@media (max-width: 480px) {
  body {
    font-size: 0.85rem;                 /* texto base más pequeño */
  }

  .card {
    padding: 0.8rem;
  }

  .title {
    font-size: 1rem;
  }

  /* Botón más compacto */
  #refresh-btn {
    font-size: 0.85rem;
    padding: 0.6rem;
  }

  /* Logos más pequeños y redondos */
  .bank-logo {
    width: 45px;
    height: 45px;
    min-width: 40px;
  }

  .bank-logo img {
    width: 70%;
    height: 70%;
  }

  /* Texto de banco y precio más pequeño */
  .bank-name,
  .price-cell {
    font-size: 0.95rem;
    font-weight: 700;
  }

  /* Íconos de tendencia más pequeños */
  .trend-icon {
    font-size: 0.9rem;
    margin-right: 4px;
  }

  #prices-table th,
  #prices-table td {
    font-size: 0.85rem;
    padding: 0.5rem;
  }

  #updated-time {
    font-size: 0.75rem;
  }

  .footer {
    font-size: 0.8rem;
    padding: 0.8rem;
  }
}

/* === Ajustes extremos para pantallas muy pequeñas (≤ 360 px) === */
@media (max-width: 360px) {
  .title {
    font-size: 0.9rem;
  }

  #refresh-btn {
    font-size: 0.75rem;
    padding: 0.5rem;
  }

  .bank-logo {
    width: 35px;
    height: 35px;
    min-width: 35px;
  }

  .bank-name,
  .price-cell {
    font-size: 0.8rem;
    font-weight: 600;
  }

  #prices-table th,
  #prices-table td {
    font-size: 0.75rem;
    padding: 0.4rem;
  }

  .trend-icon {
    font-size: 0.75rem;
  }

  #updated-time {
    font-size: 0.7rem;
  }

  .footer {
    font-size: 0.7rem;
  }
}

/* === Ajuste ultra compacto para pantallas diminutas (≤ 320 px) === */
@media (max-width: 320px) {
  .bank-logo {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }

  .bank-name,
  .price-cell {
    font-size: 0.7rem;
    font-weight: 600;
  }

  #refresh-btn {
    font-size: 0.7rem;
    padding: 0.4rem;
  }

  .trend-icon {
    font-size: 0.65rem;
  }

  #updated-time {
    font-size: 0.65rem;
  }

  .footer {
    font-size: 0.65rem;
  }
}
