/* Catálogo por estancias (js/catalogo-estancias.js) — mismos colores que la galería de muebles */
#dlg-estancias {
  --est-bg: #1e1e2e; --est-panel: #24243a; --est-line: #3a3a58; --est-text: #e6e6f0; --est-dim: #9a9ab8;
  --est-thumb: #f7f6f3;
  background: var(--est-bg); color: var(--est-text);
  border: 1px solid var(--est-line); border-radius: 10px; padding: 0;
  width: min(1180px, 97vw); max-width: 97vw; height: min(780px, 94vh); max-height: 94vh;
  position: fixed; inset: 0; margin: auto; overflow: hidden;
}
#dlg-estancias[open] { display: flex; flex-direction: column; }
#dlg-estancias::backdrop { background: rgba(0,0,0,.6); }
[data-theme="light"] #dlg-estancias {
  --est-bg: #f4f2ee; --est-panel: #fff; --est-line: #d6d2ca; --est-text: #222; --est-dim: #6b675f; --est-thumb: #fff;
}

.est-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--est-line); }
.est-title { font-weight: 600; font-size: 14px; white-space: nowrap; }
.est-search {
  flex: 1; min-width: 0; max-width: 380px; margin-left: auto;
  background: var(--est-panel); color: var(--est-text); border: 1px solid var(--est-line);
  border-radius: 6px; padding: 6px 10px; font-size: 13px;
}
.est-close { background: transparent; color: var(--est-dim); border: 1px solid var(--est-line); border-radius: 5px; padding: 3px 10px; cursor: pointer; }
.est-close:hover { color: var(--est-text); border-color: var(--accent); }

.est-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 170px 1fr 290px; }

/* Estancias */
.est-rooms { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border-right: 1px solid var(--est-line); overflow-y: auto; }
.est-room {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 9px;
  background: transparent; color: var(--est-text); border: 0; border-radius: 7px;
  padding: 9px 10px; font-size: 13.5px; text-align: left; cursor: pointer;
}
.est-room svg { width: 22px; height: 22px; color: var(--est-dim); }
.est-room small { color: var(--est-dim); font-size: 11px; }
.est-room:hover { background: var(--est-panel); }
.est-room.active { background: var(--accent); color: #fff; }
.est-room.active svg, .est-room.active small { color: #fff; }
.est-otros-lbl { margin: 14px 10px 4px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--est-dim); }
.est-otro {
  background: transparent; color: var(--est-text); border: 1px dashed var(--est-line); border-radius: 7px;
  padding: 7px 10px; font-size: 12.5px; text-align: left; cursor: pointer;
}
.est-otro:hover { border-color: var(--accent); border-style: solid; }

/* Grupos + rejilla */
.est-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.est-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 8px; border-bottom: 1px solid var(--est-line); }
.est-tab {
  background: transparent; color: var(--est-dim); border: 1px solid var(--est-line); border-radius: 999px;
  padding: 4px 13px; font-size: 12.5px; cursor: pointer;
}
.est-tab:hover { color: var(--est-text); }
.est-tab.active { background: var(--est-text); color: var(--est-bg); border-color: var(--est-text); }
.est-tab-info { font-size: 12.5px; color: var(--est-dim); padding: 4px 0; }
.est-grid {
  flex: 1; overflow-y: auto; padding: 14px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: min-content; gap: 10px;
}
.est-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--est-panel); color: var(--est-text); border: 1.5px solid var(--est-line); border-radius: 8px;
  padding: 7px; cursor: pointer; font: inherit;
}
.est-card:hover { border-color: var(--accent); }
.est-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.est-thumb { aspect-ratio: 4 / 3; background: var(--est-thumb); border-radius: 5px; display: flex; align-items: center; justify-content: center; padding: 8px; }
.est-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.est-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.est-dims { font-size: 11px; color: var(--est-dim); }
.est-empty { grid-column: 1 / -1; color: var(--est-dim); font-size: 13px; }

/* Ficha */
.est-detail { border-left: 1px solid var(--est-line); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.est-preview { aspect-ratio: 1; background: var(--est-thumb); border-radius: 7px; display: flex; align-items: center; justify-content: center; padding: 14px; }
.est-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.est-detail h3 { margin: 0; font-size: 15px; }
.est-fields { display: flex; flex-direction: column; gap: 6px; }
.est-fields label { display: grid; grid-template-columns: 50px 1fr 28px; align-items: center; gap: 8px; font-size: 12.5px; color: var(--est-dim); }
.est-fields input {
  background: var(--est-bg); color: var(--est-text); border: 1px solid var(--est-line); border-radius: 5px;
  padding: 5px 8px; font-size: 13px; text-align: right; width: 100%; box-sizing: border-box;
}
.est-fields span { font-size: 11px; }
.est-fields label:has(select) { grid-template-columns: 50px 1fr 28px; }
.est-fields select {
  background: var(--est-bg); color: var(--est-text); border: 1px solid var(--est-line); border-radius: 5px;
  padding: 5px 6px; font-size: 13px; width: 100%; box-sizing: border-box;
}
.est-chips-lbl { font-size: 11.5px; color: var(--est-dim); }
.est-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.est-chip {
  background: transparent; color: var(--est-text); border: 1px solid var(--est-line); border-radius: 5px;
  padding: 3px 8px; font-size: 12px; cursor: pointer;
}
.est-chip:hover { border-color: var(--accent); }
.est-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.est-guide { margin: 0; font-size: 12px; line-height: 1.45; padding: 8px 10px; border-radius: 6px; background: var(--est-panel); border-left: 3px solid var(--accent); }
.est-legs { margin: 0; font-size: 12px; line-height: 1.45; padding: 8px 10px; border-radius: 6px; border: 1px solid #3f9f6a; color: var(--est-text); }
.est-legs.mal { border-color: #d0593b; background: color-mix(in srgb, #d0593b 12%, transparent); }
.est-note { margin: 0; font-size: 11.5px; color: var(--est-dim); line-height: 1.4; }
.est-create {
  margin-top: auto; background: var(--accent); color: #fff; border: 0; border-radius: 7px;
  padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.est-create:hover { filter: brightness(1.1); }

.est-addto { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--est-line); font-size: 12.5px; color: var(--est-dim); cursor: pointer; }
.est-addto input { accent-color: var(--accent); }

/* Móvil: estancias arriba en fila, ficha debajo */
@media (max-width: 760px) {
  .est-title { display: none; }
  .est-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; overflow-y: auto; }
  .est-rooms { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--est-line); }
  .est-room { grid-template-columns: 20px auto; white-space: nowrap; }
  .est-room small { display: none; }
  .est-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .est-detail { border-left: 0; border-top: 1px solid var(--est-line); }
  .est-preview { display: none; }
}
