/* 1. Box sizing */
*, *::before, *::after { box-sizing: border-box; }

/* 2. Variables */
:root {
  --bg: #0D0D0D;
  --card-bg: #161616;
  --footer-bg: #222222;
  --border: #2A2A2A;
  --accent: #D36B1B;
  --text-main: #FFFFFF;
  --text-sec: #E5E5E5;
  --text-disabled: #808080;
  --tab-inactive-bg: #1C1C1C;
}

/* 3. Layout */
html, body {

  background: var(--bg);
  color: var(--text-main);
  display: flex;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  width: 90%;
  margin: 24px auto;
}

.sidebar {
  width: 3rem;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-sec);
  font-weight: bold;
  text-transform: uppercase;
  font-size: .8rem;
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  flex-shrink: 0; /* Asegura que la barra lateral no se comprima */
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: calc(100% - 3rem); /* Asegura que tome todo el espacio restante */
}

.header {
  display: flex;
  background: var(--tab-inactive-bg);
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: .8rem 1rem;
  text-align: center;
  background: var(--tab-inactive-bg);
  color: var(--text-disabled);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .3s;
}

.tab.active {
  background: var(--accent);
  color: var(--text-main);
}

.search-bar {
  margin: 1rem;
  display: flex;
  justify-content: center;
}

.search-bar input {
  width: 300px;
  padding: .4rem .8rem;
  background: var(--footer-bg);
  color: var(--text-sec);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.search-bar input::placeholder {
  color: var(--text-disabled);
}

/* MODIFICACIÓN PRINCIPAL: Grid fija a 3 columnas */
.grid {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* Fuerza exactamente 3 columnas equilibradas */
  gap: 1rem;
  align-content: start; /* Evita que las tarjetas se estiren verticalmente si hay pocas */
  width: 100%;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .2s;
      height: max-content;
}

.card:hover {
  transform: translateY(-5px);
}

.card .image {
  position: relative;
  padding-top: 56.25%;
  background: radial-gradient(circle at center, #000a, #0007);
}

.card .image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #0001, transparent);
}

.card .image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
      object-position: top;
}

.card .footer {
  background: var(--footer-bg);
  padding: .5rem .8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-sec);
  font-size: .9rem;
  flex-shrink: 0;
}

.card .footer .name {
  font-weight: bold;
  text-transform: uppercase;
}

.card .footer .icon {
  margin-right: .3rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity .3s;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal {
  position: relative;
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 4px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text-main);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}

.modal h2 {
  margin-top: 0;
}

.modal .close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal .detail p {
  margin: .4rem 0;
}

/* Adaptación responsive para pantallas pequeñas */
@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .grid {
    grid-template-columns: 1fr;
  }
}


/* Cambios en la barra de búsqueda (opcional, para que aproveche todo el ancho superior) */
.search-bar {
  margin: 1rem;
  display: flex;
  justify-content: stretch; /* Se estira a lo ancho si el input tiene width: 100% */
}

.search-bar input {
  width: 100%; /* O sube el valor si quieres que sea más ancho, ej. 100% en lugar de 300px */
  padding: .4rem .8rem;
  background: var(--footer-bg);
  color: var(--text-sec);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* MODIFICACIÓN PRINCIPAL: Grid al 100% del ancho */
.grid {
  flex: 1;
  padding: 0; /* 1. Cambiado de 1rem a 0 para que choque con los bordes laterales */
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  align-content: start;
  width: 100%; /* 2. Garantiza que ocupe el 100% del contenedor main */
  box-sizing: border-box;
}