/* ================== HOME HEADER ================== */
.header-home {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .header-home {
    margin-bottom: 0;
  }
}

.header-home h2 {
  margin-bottom: 0;
  color: white;
  font-size: 1.8rem;
  flex: 1 1 auto;
}

.btn-mapa {
  --mapa-scale: 1;
  --mapa-shake: 0;
  --mapa-color-main: var(--primary);
  --mapa-color-alt: var(--secondary);
  --mapa-color-hover: var(--primary-dark);
  --mapa-color-active: var(--primary-dark);
  background: var(--mapa-color-main);
  color: var(--white);
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 1rem;
  min-width: 60px;
  min-height: 32px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
  animation: mapaShake 3s infinite ease-in-out;
  transform: translateX(calc(var(--mapa-shake) * 1px)) scale(var(--mapa-scale));
  transform-origin: center;
}

.btn-mapa:hover {
  background-color: var(--mapa-color-hover);
  --mapa-scale: 1.05;
  animation-play-state: paused;
}

.btn-mapa:active {
  background-color: var(--mapa-color-active);
  --mapa-scale: 0.95;
  animation-play-state: paused;
}

.btn-mapa[data-mode="lista"] {
  --mapa-color-main: var(--secondary);
  --mapa-color-alt: var(--primary);
  --mapa-color-hover: var(--secondary-light);
  --mapa-color-active: var(--secondary);
}
/* ================== VARIABLES ================== */
:root {
  --primary: #234f9e;
  --primary-light: #3d5f9f;
  --primary-dark: #19376f;
  --secondary: #e23c1b;
  --secondary-light: #e2573c;
  --accent: #e74c3c;
  --light: #ecf0f1;
  --dark: #2c3e50;
  --gray: #95a5a6;
  --gray-light: #bdc3c7;
  --white: #fff;
  --black: #222;
  --background: #f5f5f5;
  --background-dark: #09152c;
  --text: #333;
  --text-dark: #ddd;
  --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.2);
  --transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
}

/* ================== RESET ================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-dark);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ================== SECCIONES ================== */
.section {
  display: block;
  animation: fadeIn 0.5s ease;
  margin-bottom: 1rem;
}

.section:not(.active-section) {
  display: none;
}

.section h2 {
  color: white;
  margin-bottom: 0rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 1.8rem;
}

.main-content {
  min-height: 800px;
  width: 90%;
  justify-content: center;
  margin: 0 auto;
}

h2.main-title {
  color: white;
  margin-bottom: 0rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 1.85rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================== CARDS DE PROVINCIAS ================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.5rem;
  margin: 1rem 0;
}

.card {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: pointer;
  height: auto;
  width: auto;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.card-img-container {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}


.card-img {
  padding-bottom: 10px;
  height: 100%;
  object-fit: contain;
  transition: var(--transition);
  animation: cardImgBounce 3s infinite;
  z-index: 10;
  position: relative;
  scale: 0.95;
}

@keyframes cardImgBounce {

  0%,
  100% {
    transform: scale(0.95) translateY(0);
    filter: drop-shadow(0 4px 7px rgba(0, 79, 158, 0.1));
  }

  40%,
  60% {
    transform: scale(1.05) translateY(-3px);
    filter: drop-shadow(0 4px 7px rgba(0, 79, 158, 0.6));
  }
}

.card-body {
  padding: 0rem 0.2rem;
  text-align: center;
  background-color: transparent;
}

.card-title {
  font-weight: 600;
  color: var(--primary);
  font-size: 1.1rem;
}

.card-meta {
  font-size: 0.85rem;
  color: var(--gray);
}

/* ================== TERMINALES ================== */
#terminal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

/* ================== COOPERATIVAS ================== */
#cooperative-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  grid-auto-flow: dense;
  gap: 1rem;
  align-items: start;
}

.cooperative-card {
  position: relative;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  padding: 0rem 0rem 0rem 0rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cooperative-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.cooperative-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1));
  pointer-events: none;
  z-index: 0;
}

.cooperative-card.expanded,
.cooperative-card.open {
  overflow: visible;
}

.cooperative-card>* {
  position: relative;
  z-index: 1;
}

/* ================== ACORDEÓN ================== */
.coop-header {
  background: var(--primary);
  color: var(--text-dark);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  user-select: none;
}

.coop-header:hover {
  background-color: var(--primary-dark);
}

.coop-logo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid white;
}

.coop-info {
  flex-grow: 1;
}

.coop-info h3 {
  margin: 0;
  font-size: 1rem;
}

.coop-rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  margin-top: 0.3rem;
  color: var(--light);
}

.coop-rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Esto separa izquierda y derecha */
  margin-top: 0.3rem;
  gap: 0.5rem;
}

/* Botón de alternar */
.accordion-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-dark);
  transition: transform 0.3s ease;
  transform: rotate(0deg);
}

.accordion-toggle[aria-expanded="true"] {
  transform: rotate(90deg);
}

/* ACORDEÓN: transición slide-down real y scroll interno */
.coop-body {
  overflow-y: auto;
  max-height: 0;
  opacity: 0;
  padding: 0;
  transition: max-height 0.5s cubic-bezier(.4, 0, .2, 1), opacity 0.5s cubic-bezier(.4, 0, .2, 1), padding 0.5s cubic-bezier(.4, 0, .2, 1);
  display: block;
  will-change: max-height, opacity, padding;
}

.coop-body.open {
  max-height: 315px;
  /* Ajusta según el contenido máximo esperado */
  opacity: 1;
  padding: 0.2rem 0.5rem;
  transition: max-height 0.5s cubic-bezier(.4, 0, .2, 1), opacity 0.5s cubic-bezier(.4, 0, .2, 1), padding 0.5s cubic-bezier(.4, 0, .2, 1);
  overflow-y: auto;
}

/* ================== MODAL INFO ================== */
.info-container {
  position: relative;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.98);
  transition: opacity 0.4s cubic-bezier(.4, 0, .2, 1), transform 0.4s cubic-bezier(.4, 0, .2, 1), height 0.4s cubic-bezier(.4, 0, .2, 1), margin 0.4s, padding 0.4s;
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  height: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  max-width: 100%;
  width: auto;
  overflow: hidden;
}

.info-container.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  height: auto;
  margin: 0.5rem 1rem 0.5rem 1rem;
  padding: 0.7rem 1rem;
  overflow: visible;
}

/* Filas individuales del modal info */
.info-row {
  display: flex;
  align-items: center;
  margin: 8px 0;
  padding: 5px 0;
  border-bottom: 1px solid var(--light);
  width: 100%;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row i {
  margin-right: 10px;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.info-row a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.info-row a:hover {
  text-decoration: none;
  color: var(--primary-dark);
}

.phone-display {
  text-decoration: none !important;

}

.info-row.redes {
  width: 100%;
  justify-content: space-around;
}

.info-row.redes i {
  color: var(--secondary);
  font-size: 1.2rem;
  transition: color 0.3s ease;
}

.info-row.redes i:hover {
  color: var(--secondary-light);
}

/* ================== INFO BTN ================== */
.info-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  align-items: center;
  display: flex;
  scale: 1.5;
  margin-right: 10px;
}

.info-icon {
  margin-left: 0;
  color: rgba(255, 255, 255, 0.455);
  cursor: pointer;
  font-size: 1.2em;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.15), rgba(192, 57, 43, 0.15)) !important;
  border-radius: 50%;
  padding: 0;
  border: none;
  transition: all 0.3s ease;
  box-shadow: none;
  animation: pulse 2.5s ease-in-out infinite;
  will-change: transform, box-shadow;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.info-icon:hover {
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  color: var(--white);
  transform: scale(1.25);
  box-shadow: 0 6px 12px rgba(231, 76, 60, 0.4);
}

@keyframes pulse {

  0% {
    transform: scale(1) rotate(0deg) translateZ(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  15% {
    transform: scale(1.03) rotate(-3deg) translateZ(0);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.25);
  }

  30% {
    transform: scale(1.06) rotate(3deg) translateZ(0);
    box-shadow: 0 8px 20px rgba(231, 76, 60, 0.35);
  }

  45% {
    transform: scale(1.08) rotate(-2deg) translateZ(0);
    box-shadow: 0 12px 30px rgba(231, 76, 60, 0.45);
  }

  60% {
    transform: scale(1.06) rotate(2deg) translateZ(0);
    box-shadow: 0 8px 20px rgba(231, 76, 60, 0.35);
  }

  75% {
    transform: scale(1.03) rotate(-1deg) translateZ(0);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.25);
  }

  90% {
    transform: scale(1.01) rotate(1deg) translateZ(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  100% {
    transform: scale(1) rotate(0deg) translateZ(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
}

/* ================== LOCATION BTN ================== */
.location-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  align-items: center;
  display: flex;
  scale: 1.5;
  margin-right: 10px;
}

.location-icon {
  margin-left: 0;
  color: rgba(255, 255, 255, 0.455);
  cursor: pointer;
  font-size: 1.2em;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.15), rgba(41, 128, 185, 0.15)) !important;
  border-radius: 50%;
  padding: 0;
  border: none;
  transition: all 0.3s ease;
  box-shadow: none;
  animation: pulse 2.5s ease-in-out infinite;
  will-change: transform, box-shadow;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.location-icon:hover {
  background: linear-gradient(135deg, #3498db, #5dade2);
  color: var(--white);
  transform: scale(1.25);
  box-shadow: 0 6px 12px rgba(52, 152, 219, 0.4);
}

@keyframes pulseLocation {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
  }
}

/* ================== RUTAS ================== */
.route {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.route:last-child {
  border-bottom: none;
}

.route-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.route-schedule {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.time {
  background: #f0f0f0;
  padding: 0.3rem 0.6rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  box-shadow: 0 1px 4px rgba(44, 79, 158, 0.07);
}

.time:hover {
  background: var(--primary);
  color: var(--white);
  transform: scale(1.08);
}

.time:active {
  background: var(--secondary);
  color: var(--white);
  transform: scale(0.95);
}

.time.active-time {
  background: var(--secondary);
  color: var(--white);
  transform: scale(0.95);
}

.route-price {
  margin-top: 0.5rem;
  font-weight: bold;
  color: var(--accent);
}

/* ================== TOOLTIP ================== */
#tooltip {
  display: none;
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid #ccc;
  padding: 5px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  max-width: 250px;
  font-size: 0.9rem;
}

/* ================== ERROR ================== */
.error {
  text-align: center;
  padding: 2rem;
  color: var(--accent);
  grid-column: 1 / -1;
}

.error i {
  font-size: 2rem;
  margin-bottom: 1rem;
}

/* ================== RESPONSIVE ================== */
@media (max-width: 1024px) {
  #cooperative-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .card-grid,
  #terminal-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  #cooperative-container {
    grid-template-columns: 1fr;
  }

  .main-content {
    width: 100%;
    justify-content: center;
    margin: 0 auto;
  }

  .section h2 {
    font-size: 1rem;
  }

  .accordion-toggle {
    display: inline-block;
  }

  #cooperative-section h2 {
    flex-wrap: wrap;
  }

  .toggle-all-btn {
    font-size: 0.9rem;
    padding: 0.4rem;
  }
}

@media (max-width: 375px) {

  .card-grid,
  #terminal-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .card-body {
    padding: 0 0.5rem;
    text-align: center;
  }

  .card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    height: auto;
  }

  .card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
  }

  .card-img-container {
    height: 60px;
  }

  .card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: var(--transition);
  }

  .card-title {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
  }

  .card-meta {
    font-size: 0.55rem;
    color: var(--gray);
  }

  .coop-header {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .coop-rating {
    padding: 0.2rem 0.5rem;
    font-weight: 500;
    gap: 0.2rem;
    font-size: small;
  }

  .info-icon {
    font-size: 1rem;
  }

  .coop-body.open {
    max-height: 250px;
  }

  .coop-body {
    max-height: 0;
  }
}

@media (max-width: 320px) {

  .card-grid,
  #terminal-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .section h2 {
    font-size: 1rem;
  }

  .toggle-all-btn {
    font-size: 0.7rem;
    padding: 0.2rem;
  }
}

/* ================== BOTÓN MOSTRAR TODAS ================== */
.toggle-all-btn {
  background-color: var(--primary);
  color: var(--white);
  border: none;
  padding: 0.5rem;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.toggle-all-btn:hover {
  background-color: var(--primary-dark);
  transform: scale(1.05);
}

.toggle-all-btn:active {
  transform: scale(0.95);
}

@media (max-width: 768px) {
  .toggle-all-btn {
    font-size: 0.9rem;
    padding: 0.4rem;
  }
}

@media (max-width: 576px) {
  .toggle-all-btn {
    font-size: 0.8rem;
    padding: 0.3rem;
  }
}

/* ================== OTROS ================== */
#btn-home.inactive {
  background-color: var(--gray-light) !important;
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

/* ================== HEADER CONTAINER ================== */
.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  margin-bottom: 0.5rem;
  width: 100%;
}

.header-title {
  display: inline-flex;
  align-items: center;
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  margin-bottom: 0;
  min-width: 0;
  color: #fff;
  white-space: nowrap !important;
  overflow: hidden;
  flex: 1 1 auto;
  max-width: calc(100% - 40px);
  /* Deja espacio para el botón */
}

.toggle-all-btn {
  flex-shrink: 0;
  min-width: 28px;
  min-height: 28px;
  width: 32px;
  /* Ancho fijo para el cálculo */
  font-size: 1.1rem;
  padding: 0.2rem;
  border-radius: 6px;
  height: 32px;
  align-self: center;
}

/* Responsive: en pantallas muy pequeñas, permite que el texto se corte pero nunca baja el botón */
@media (max-width: 500px) {

  .header-container h2,
  #current-terminal-name {
    font-size: 0.80rem;
  }

  .toggle-all-btn {
    font-size: 1rem;
    padding: 0.1rem;
    width: 20px;
    height: 20px;
  }
}

.verificado-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  margin-right: 0.7em;
}

.verificado-icon {
  color: var(--secondary);
  font-size: 1.1em;
  vertical-align: middle;
}

.verificado-text {
  color: white;
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.terminal-location {
  margin-top: 0.3em;
}

.terminal-location a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.8em;
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
}

.terminal-location .location-icon {
  color: var(--primary);
  font-size: 1.1em;
  vertical-align: middle;
}

@keyframes mapaShake {
  0%, 70%, 100% {
    --mapa-shake: 0;
    background-color: var(--mapa-color-main);
  }
  72% {
    --mapa-shake: -3;
    background-color: var(--mapa-color-alt);
  }
  74% {
    --mapa-shake: 3;
    background-color: var(--mapa-color-hover);
  }
  76% {
    --mapa-shake: -3;
    background-color: var(--mapa-color-alt);
  }
  78% {
    --mapa-shake: 3;
    background-color: var(--mapa-color-hover);
  }
  80% {
    --mapa-shake: 0;
    background-color: var(--mapa-color-main);
  }
}