:root {
  /* Escala fluida */
  --fs-xs: clamp(11px, 1.2vw, 12px);
  --fs-sm: clamp(12px, 1.4vw, 13px);
  --fs-md: clamp(13px, 1.6vw, 14px);
  --fs-lg: clamp(15px, 2vw, 16px);
  --fs-xl: clamp(17px, 2.6vw, 18px);

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
}

/* ===============================
   RESET
================================ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  color: #111;
  -webkit-font-smoothing: antialiased;
}

/* ===============================
   LAYOUT GENERAL
================================ */
.app {
  display: grid;
  grid-template-columns: 1fr 360px;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "center filters"
    "downloads filters";
  height: 100vh;
}

/* ===============================
   CENTER
================================ */
#center {
  grid-area: center;
  
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* ===============================
   SCENES
================================ */
#scenes {
    display: flex;
    gap: 12px;
    padding: 21px;
    border-bottom: 1px solid #e5e7eb;
}
.scene {
  width: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
}

.scene img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene.active {
  border-color: #111;
}

/* ===============================
   RENDER
================================ */
#render {
  position: relative;
  flex: 1;
  border-radius: 16px;
  overflow: hidden;
}

#render img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#render-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-md);
  color: #9ca3af;
}

/* ===============================
   DESCARGAS
================================ */
#downloads {
  grid-area: downloads;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#downloads p {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: #6b7280;
  white-space: nowrap;
}

#downloads button {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
}

#downloads button:hover {
  background: #111;
  color: #fff;
}

/* ===============================
   FILTROS
================================ */
#filters {
  grid-area: filters;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  padding: 24px;
  overflow-y: auto;
}

.filter {
  margin-bottom: 28px;
}

.filter strong {
  display: block;
  margin-bottom: 10px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

.filter-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-content button {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.filter-content button:hover,
.filter-content button.active {
  background: #111;
  color: #fff;
}

/* ===============================
   TEXTURAS
================================ */
#textures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.texture {
  aspect-ratio: 1;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  border: 2px solid transparent;
}

.texture.active {
  border-color: #111;
}

/* ===============================
   PRINT
================================ */
#print-summary {
  display: none;
}

@media print {
  #filters,
  #downloads,
  #scenes {
    display: none !important;
  }

  #print-summary {
    display: block;
    margin-top: 20px;
    font-size: var(--fs-sm);
  }

  #print-summary h2 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin-bottom: 10px;
  }

  #print-summary ul {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
  }

  #print-summary li {
    margin-bottom: 4px;
  }

  .print-texture img {
    width: 120px;
    height: auto;
    border: 1px solid #ccc;
  }

  #render {
    width: 100%;
    height: auto;
  }

  #render img {
    position: static;
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  #render-base {
    display: none !important;
  }

  #render-textura {
    display: block !important;
  }

  @page {
    margin: 12mm;
  }
}

/* ===============================
   RESPONSIVE
================================ */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "center"
      "downloads"
      "filters";

    height: auto;
    min-height: unset;
  }

  #render {
    min-height: auto;
    aspect-ratio: 4 / 3;
    flex: none;
  }
}

@media (max-width: 768px) {
  .filter-content {
    display: none;
  }

  .filter.open .filter-content {
    display: flex;
  }

  #textures {
    grid-template-columns: repeat(2, 1fr);
  }
}
