/* =========================================================================
   Inteligencia Dubai — estilos
   Estética: oscuro elegante con acento dorado/cian (real estate Dubái)
   ========================================================================= */
:root {
  --bg: #0b0f14;
  --panel: rgba(18, 24, 32, 0.92);
  --panel-solid: #121820;
  --ink: #eef3f8;
  --muted: #9fb0c0;
  --line: rgba(255, 255, 255, 0.10);
  --gold: #d4af37;
  --gold-soft: #e7c969;
  --cyan: #00e5ff;
  --danger: #ff5d6c;
  --ok: #45d483;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --topbar-h: 60px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--cyan); text-decoration: none; }

/* ----------------------------- BARRA SUPERIOR --------------------------- */
#topbar {
  position: relative; flex: 0 0 auto; min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 0 16px; z-index: 40;
  background: linear-gradient(180deg, rgba(11,15,20,0.96), rgba(11,15,20,0.82));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; white-space: nowrap; }
.brand-mark { color: var(--gold); font-size: 16px; }
.brand-text { letter-spacing: .3px; }
.brand-text strong { color: var(--gold); font-weight: 700; }

.search-wrap { display: flex; align-items: center; flex: 1 1 360px; max-width: 460px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 4px 4px 14px; }
#search-input { flex: 1; background: transparent; border: none; color: var(--ink);
  outline: none; font-size: 14px; }
#search-input::placeholder { color: var(--muted); }

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: nowrap; }

.view-toggle { display: inline-flex; background: rgba(255,255,255,0.06);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg { background: transparent; border: none; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.seg.active { background: var(--gold); color: #1a1205; font-weight: 600; }

.primary-btn { background: var(--gold); color: #1a1205; border: none;
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.primary-btn:hover { background: var(--gold-soft); }
.primary-btn.block { width: 100%; padding: 11px; }
.ghost-btn { background: rgba(255,255,255,0.05); color: var(--ink);
  border: 1px solid var(--line); padding: 7px 12px; border-radius: 10px; font-size: 13px; }
.ghost-btn:hover { background: rgba(255,255,255,0.10); }
.ghost-btn.small, .danger-btn.small { padding: 5px 9px; font-size: 12px; }
.danger-btn { background: rgba(255,93,108,0.12); color: var(--danger);
  border: 1px solid rgba(255,93,108,0.4); padding: 7px 12px; border-radius: 10px; font-size: 13px; }
.danger-btn:hover { background: rgba(255,93,108,0.22); }
.icon-btn { background: var(--gold); color:#1a1205; border:none; border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; }
.count { background: rgba(0,0,0,0.25); border-radius: 999px; padding: 0 7px; margin-left: 2px; font-size: 12px; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px; white-space: nowrap; }

/* ----------------------------- ESCENARIO / MAPA ------------------------- */
#stage { position: relative; flex: 1 1 auto; min-height: 0; }
.map-layer { position: absolute; inset: 0; }
.hidden { display: none !important; }

#dld-layer { background: #0b0f14; display: flex; flex-direction: column; }
.dld-bar { height: 38px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--panel-solid); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted); }
#dld-frame { flex: 1; width: 100%; border: none; }
.dld-fallback { position: absolute; inset: 38px 0 0 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px; }

.attribution { position: absolute; left: 10px; bottom: 8px; font-size: 11px;
  color: rgba(255,255,255,0.55); background: rgba(0,0,0,0.35); padding: 3px 8px; border-radius: 6px; }

.overlay-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #16202c, #0b0f14); z-index: 5; }
.overlay-card { background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 32px; max-width: 460px; box-shadow: var(--shadow); }
.overlay-card h2 { margin: 0 0 10px; color: var(--gold); }
.overlay-card code { background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 5px; }

/* ----------------------------- PANELES LATERALES ------------------------ */
.side-panel { position: absolute; top: 14px; bottom: 14px; width: 380px; max-width: 92vw;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(14px); z-index: 30;
  display: flex; flex-direction: column; overflow: hidden; }
.side-panel.left { left: 14px; }
.side-panel.right { right: 14px; }
.side-head { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); }
.side-head h3 { margin: 0; font-size: 17px; }
.close-x { background: transparent; border: none; color: var(--muted); font-size: 16px; line-height: 1; }
.close-x:hover { color: var(--ink); }
.side-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; }

.detail-meta { padding: 12px 18px 0; display: flex; flex-direction: column; gap: 4px; }
.detail-address { color: var(--muted); font-size: 13px; }
.detail-updated { color: var(--gold-soft); font-size: 12px; }

/* listado de proyectos */
.projects-list { overflow-y: auto; padding: 8px; flex: 1; }
.proj-item { padding: 12px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; }
.proj-item:hover { background: rgba(255,255,255,0.06); border-color: var(--line); }
.proj-item h4 { margin: 0 0 3px; font-size: 14px; }
.proj-item .addr { font-size: 12px; color: var(--muted); }
.empty-list { color: var(--muted); padding: 24px; text-align: center; font-size: 14px; }

/* tabs detalle */
.tabs { display: flex; gap: 4px; padding: 12px 14px 0; border-bottom: 1px solid var(--line); }
.tab { background: transparent; border: none; color: var(--muted); padding: 8px 10px;
  font-size: 13px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--gold); }
.tab-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.operativa-text { white-space: pre-wrap; line-height: 1.55; font-size: 14px; color: #dde6ee; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.gallery img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); }
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.doc-row:hover { background: rgba(255,255,255,0.08); }
.doc-ic { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 7px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #1a1205; background: var(--gold); }
.doc-ic.html { background: var(--cyan); }
.doc-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { color: var(--muted); text-align: center; padding: 30px; }

/* ----------------------------- MODALES ---------------------------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(3,6,10,0.66); backdrop-filter: blur(4px); padding: 24px; }
.modal.dark { background: rgba(0,0,0,0.9); }
.modal-card { background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; display: flex; flex-direction: column; position: relative; }
.modal-card.small { max-width: 380px; padding: 26px; }
.modal-card.medium { max-width: 560px; max-height: 90vh; }
.modal-card.large { max-width: 1000px; height: 88vh; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-head-actions { display: flex; gap: 8px; align-items: center; }
.modal-close { position: static; }
.modal-body { flex: 1; overflow: auto; padding: 0; }
.modal-body.form-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.doc-frame { width: 100%; height: 100%; border: none; background: #fff; }
.doc-body { position: relative; background: #0b0f14; }
.doc-img { width: 100%; height: 100%; object-fit: contain; display: block; background: #0b0f14; }
#lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; }

.modal-card.small h2 { margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

/* ----------------------------- PANELES FLOTANTES ------------------------ */
.floating-panel { position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  width: 360px; max-width: 92vw; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(14px);
  z-index: 35; padding: 14px 16px; }
.fp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fp-head h3 { margin: 0; font-size: 15px; }
.fp-label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; }
.fp-input { width: 100%; background: rgba(255,255,255,0.06); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; color: var(--ink); font-size: 13px; outline: none; }
.fp-input:focus { border-color: var(--gold); }
.fp-range { width: 100%; accent-color: var(--gold); }
textarea.fp-input { resize: vertical; }
.dist-dest-row { display: flex; gap: 8px; }
.dist-dest-row .fp-input { flex: 1; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset-chip { background: rgba(0,229,255,0.1); border: 1px solid rgba(0,229,255,0.35);
  color: var(--cyan); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.preset-chip:hover { background: rgba(0,229,255,0.2); }
.dist-result { margin-top: 12px; padding: 12px; background: rgba(212,175,55,0.08);
  border: 1px solid rgba(212,175,55,0.3); border-radius: 10px; font-size: 14px; }
.dist-result b { color: var(--gold-soft); }

/* formulario */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.06);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 12px; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.chip button { background: transparent; border: none; color: var(--danger); font-size: 13px; }
.chip.existing { border-style: dashed; }
.file-btn { background: rgba(255,255,255,0.06); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 12px; font-size: 13px; cursor: pointer; }

/* ----------------------------- CARGA / TOAST ---------------------------- */
.loading { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; background: rgba(3,6,10,0.6); backdrop-filter: blur(3px); }
.spinner { width: 42px; height: 42px; border: 3px solid rgba(255,255,255,0.18);
  border-top-color: var(--gold); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--panel-solid); border: 1px solid var(--line); color: var(--ink);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; max-width: 90vw; }
.toast.ok { border-color: rgba(69,212,131,0.5); }
.toast.err { border-color: rgba(255,93,108,0.5); }

/* ----------------------------- RESPONSIVE ------------------------------- */
/* ----------------------------- SELECTOR DE IDIOMA ----------------------- */
.lang-toggle { display: inline-flex; background: rgba(255,255,255,0.06);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang-toggle .seg { padding: 6px 11px; font-weight: 600; }

/* ------------------ CONTRASTE: panel de distancias / selects ------------ */
.floating-panel { background: rgba(15, 21, 29, 0.98); border-color: rgba(255,255,255,0.16); }
.fp-label { color: #cdd9e5; }                 /* etiquetas más legibles */
.fp-input { color: #f3f7fb; }
.fp-input::placeholder { color: #8fa1b3; }
select.fp-input { color: #f3f7fb; }
select.fp-input option { background: #141b24; color: #f3f7fb; }  /* opciones legibles en oscuro */
.dist-result { color: #f1f5f9; }
.dist-result b { color: var(--gold-soft); }

/* ------------------ PROYECTOS: nombre, descripción, visibilidad -------- */
.proj-item { border-left: 3px solid rgba(212,175,55,0.5); display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.proj-item:hover { border-left-color: var(--gold); }
.proj-main { flex: 1; min-width: 0; cursor: pointer; }
.proj-item h4 { font-size: 15px; color: #ffffff; letter-spacing: .2px; }
.proj-item .addr { font-size: 12px; color: #93a4b5; }
.proj-item .desc { font-size: 12.5px; color: #c7d4e0; margin-top: 5px; line-height: 1.45; }
.detail-desc { color: #dbe6f0; font-size: 13.5px; line-height: 1.5; margin-top: 2px; }
.proj-item.is-hidden { opacity: 0.55; border-left-color: rgba(255,255,255,0.18); }
.proj-toggle { flex: 0 0 auto; align-self: center; border: 1px solid var(--line); border-radius: 999px;
  font-size: 11px; font-weight: 600; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.proj-toggle.on { background: rgba(69,212,131,0.16); color: #6ee7a8; border-color: rgba(69,212,131,0.5); }
.proj-toggle.off { background: rgba(255,255,255,0.06); color: #9fb0c0; }

/* ----------------------------- RESPONSIVE (MÓVIL) ----------------------- */
@media (max-width: 820px) {
  :root { --topbar-h: auto; }
  #topbar { padding: 8px 10px; gap: 8px 10px; }
  .brand { font-size: 16px; }
  .brand-mark { font-size: 14px; }

  /* fila 1: marca + buscador ; fila 2: acciones */
  .search-wrap { flex: 1 1 150px; max-width: none; }
  .top-actions { flex: 1 1 100%; margin-left: 0; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
  .top-actions .ghost-btn, #btn-projects { display: inline-flex; align-items: center; }
  .ghost-btn, .danger-btn, .primary-btn { font-size: 12px; padding: 7px 10px; }
  .seg { font-size: 12px; padding: 6px 10px; }
  .lang-toggle .seg { padding: 6px 9px; }
  .badge { display: none; }   /* "actualizado hace X" se omite en móvil para ahorrar espacio */

  /* Paneles a pantalla completa */
  .side-panel { top: 0; bottom: 0; left: 0; right: 0; width: 100%; max-width: none;
    border-radius: 0; border: none; }
  .floating-panel { top: 0; left: 0; right: 0; transform: none; width: 100%;
    max-width: none; border-radius: 0; }

  /* Modales a pantalla completa */
  .modal { padding: 0; }
  .modal-card.small, .modal-card.medium, .modal-card.large {
    width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .modal-card.small { padding: 22px; }

  .gallery { grid-template-columns: 1fr 1fr; }
  .attribution { font-size: 10px; left: 6px; bottom: 6px; }
  #lightbox img { max-width: 96vw; max-height: 80vh; }
}

/* Pantallas muy estrechas: el buscador ocupa toda su fila */
@media (max-width: 480px) {
  .search-wrap { flex: 1 1 100%; order: 3; }
  .brand-text { font-size: 15px; }
}
