/* =========================================================
   SIG DANPAVA SIMPLE
   Funciones sencillas + identidad visual public_html
   ========================================================= */

:root {
  --vino-profundo: #3b0712;
  --vino-oscuro: #57101f;
  --vino: #781c30;
  --vino-medio: #963247;
  --vino-claro: #c05d70;
  --rosa-suave: #f7e3e7;
  --rosa-claro: #fcf3f5;
  --blanco: #ffffff;
  --tinta: #24171b;
  --muted: #75676c;
  --linea: rgba(120, 28, 48, .17);
  --sombra: 0 14px 34px rgba(59, 7, 18, .11);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--tinta);
  background: radial-gradient( circle at 8% 0%, rgba(192, 93, 112, .17), transparent 25% ), linear-gradient( 145deg, #fbf5f6, #f5efec );
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================================
   HEADER
   ========================================================= */

.topbar {
  height: 108px;
  min-height: 108px;
  padding: 16px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  background: linear-gradient( 120deg, var(--vino-profundo), var(--vino) 72%, #8a3546 );
  box-shadow: 0 10px 32px rgba(59, 7, 18, .18);
  position: relative;
  z-index: 1200;
  overflow: hidden;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 28% -150px -10%;
  height: 260px;
  background: radial-gradient( circle, rgba(192, 93, 112, .25), transparent 65% );
  pointer-events: none;
}

/* LOGO + BLOQUE DE TEXTO */

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  position: relative;
  z-index: 2;
}

/* LOGO */

.brand-logo {
  width: 150px;
  height: 150px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow( 0 0 14px rgba(255, 210, 219, .20) );
}

/* TEXTOS */

.header-copy {
  min-width: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: #efadb9;
  font-size: .58rem;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.header-copy h1 {
  margin: 0;
  color: #fff;
  font-size: 2.25rem;
  line-height: .92;
  font-weight: 900;
  letter-spacing: -.045em;
}

.header-copy p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, .83);
  font-size: .97rem;
}

/* BOTÓN PANTALLA COMPLETA */

.icon-btn {
  position: relative;
  z-index: 2;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 12px;
  background: rgba(255, 255, 255, .09);
  color: #fff;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, .16);
}

/* =========================================================
   LAYOUT
   ========================================================= */

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 28, 48, .28) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 7px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(120, 28, 48, .26);
  border-radius: 99px;
}

/* =========================================================
   CARDS
   ========================================================= */

.panel {
  margin-bottom: 12px;
  padding: 15px;
  background: rgba(255, 255, 255, .88);
  border: 1px solid var(--linea);
  border-radius: 18px;
  box-shadow: var(--sombra);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.panel h2,
.panel h3 {
  margin: 0;
  color: var(--vino-profundo);
}

.panel h2 {
  font-size: 1.05rem;
}

.panel h3 {
  font-size: .94rem;
}

.panel p {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.panel small {
  color: var(--muted);
  font-size: .72rem;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  min-width: 26px;
  padding: 4px 8px;
  text-align: center;
  border-radius: 999px;
  background: var(--rosa-suave);
  color: var(--vino);
  font-size: .71rem;
  font-weight: 800;
}

.base-help {
  display: block;
  margin: 3px 0 10px;
}

/* =========================================================
   CONTROLS
   ========================================================= */

.primary-btn,
.secondary-btn,
.square-btn {
  border: 0;
  border-radius: 11px;
  font-weight: 760;
}

.primary-btn {
  width: 100%;
  min-height: 43px;
  padding: 10px 13px;
  margin-bottom: 6px;
  color: #fff;
  background: linear-gradient( 135deg, var(--vino-oscuro), var(--vino) );
  box-shadow: 0 9px 18px rgba(120, 28, 48, .16);
}

.primary-btn:hover {
  background: linear-gradient( 135deg, var(--vino), var(--vino-medio) );
}

.secondary-btn {
  min-height: 40px;
  padding: 9px 12px;
  color: #fff;
  background: var(--vino);
}

.square-btn {
  width: 43px;
  min-width: 43px;
  color: #fff;
  background: var(--vino);
}

input[type="text"],
input[type="search"],
input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--linea);
  border-radius: 11px;
  outline: none;
  color: var(--tinta);
  background: rgba(255, 255, 255, .94);
}

input:focus {
  border-color: rgba(150, 50, 71, .65);
  box-shadow: 0 0 0 3px rgba(192, 93, 112, .12);
}

.inline-field {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* =========================================================
   LAYERS
   ========================================================= */

.layer-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.layer-item {
  min-height: 43px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--linea);
  border-radius: 11px;
  background: rgba(255, 255, 255, .9);
}

.layer-item:hover {
  border-color: rgba(150, 50, 71, .35);
}

.layer-item input[type="checkbox"] {
  accent-color: var(--vino);
}

.layer-color-picker {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
}

.layer-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.layer-color-picker::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

.layer-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: .77rem;
}

.feature-count {
  color: var(--muted);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
}

.layer-note {
  display: block;
  margin: 4px 9px 8px;
  line-height: 1.4;
}

.borough-controls {
  margin: 5px 0 9px 9px;
  color: var(--vino-profundo);
  font-size: .77rem;
}

.borough-controls summary {
  cursor: pointer;
  padding: 6px 0;
}

.borough-list {
  display: grid;
  gap: 3px;
  margin-top: 3px;
}

.borough-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--rosa-claro);
  cursor: pointer;
}

.borough-row input {
  accent-color: var(--vino);
}

.delete-layer {
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 8px;
  color: var(--vino);
  background: var(--rosa-claro);
}

.empty-state {
  padding: 12px;
  border: 1px dashed rgba(120, 28, 48, .22);
  border-radius: 11px;
  color: var(--muted);
  text-align: center;
  font-size: .76rem;
}

/* =========================================================
   SEARCH
   ========================================================= */

.search-results {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.search-result {
  padding: 8px 9px;
  border: 1px solid var(--linea);
  border-radius: 10px;
  text-align: left;
  background: #fff;
}

.search-result strong,
.search-result small {
  display: block;
}

.search-result strong {
  font-size: .78rem;
  color: var(--tinta);
}

.search-result small {
  margin-top: 2px;
  font-size: .67rem;
}

/* =========================================================
   COORDS / TOOLS
   ========================================================= */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin: 10px 0 8px;
  padding: 4px;
  border-radius: 11px;
  background: var(--rosa-claro);
}

.tab {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: .75rem;
  font-weight: 720;
}

.tab.active {
  color: #fff;
  background: var(--vino);
}

.coord-panel {
  display: none;
  gap: 7px;
}

.coord-panel.active {
  display: grid;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 9px;
}

.tool-grid button {
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 7px 4px;
  border: 1px solid var(--linea);
  border-radius: 11px;
  background: #fff;
  color: var(--vino);
  font-size: 1.05rem;
}

.tool-grid button span {
  display: block;
  font-size: .62rem;
  color: var(--muted);
}

.tool-grid button.map-off {
  background: var(--rosa-claro);
  border-color: rgba(120, 28, 48, .30);
  color: var(--muted);
}

.tool-grid button.map-off span {
  color: var(--vino);
  font-weight: 800;
}

/* =========================================================
   MAP
   ========================================================= */

.map-wrap {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--linea);
  border-radius: 20px;
  box-shadow: var(--sombra);
  background: #e9e5e2;
}

#map {
  width: 100%;
  height: 100%;
}

.map-status {
  position: absolute;
  z-index: 700;
  left: 12px;
  bottom: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px;
  color: #fff;
  background: rgba(59, 7, 18, .88);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  font-size: .69rem;
}

.mobile-sidebar-btn,
.sidebar-backdrop {
  display: none;
}

/* =========================================================
   LEAFLET
   ========================================================= */

.leaflet-bar {
  border: 0 !important;
  box-shadow: 0 7px 20px rgba(59, 7, 18, .14) !important;
}

.leaflet-bar a {
  color: var(--vino-profundo) !important;
}

.leaflet-popup-content-wrapper {
  max-width: 360px;
  border-radius: 15px;
  box-shadow: 0 16px 36px rgba(59, 7, 18, .17);
}

.popup-title {
  margin: 0 0 7px;
  color: var(--vino-profundo);
}

.popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .72rem;
}

.popup-table th,
.popup-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #eee2e5;
  vertical-align: top;
  word-break: break-word;
}

.popup-table th {
  width: 36%;
  text-align: left;
  color: var(--vino);
}

.measure-label {
  border: 0 !important;
  color: #fff !important;
  background: var(--vino-profundo) !important;
  box-shadow: none !important;
}

/* =========================================================
   TOAST
   ========================================================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 3000;
  max-width: min(420px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 11px;
  color: #fff;
  background: var(--vino-profundo);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: .2s ease;
  box-shadow: 0 14px 32px rgba(59, 7, 18, .25);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: #8e1e2c;
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1100px) and (min-width: 821px) {
  .workspace {
    grid-template-columns: 295px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .topbar {
    padding-inline: 22px;
  }

  .panel {
    padding: 13px;
  }

}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 820px) {
  .topbar {
    height: 72px;
    min-height: 72px;
    padding: 8px 10px;
    gap: 8px;
  }

  .header-brand {
    gap: 9px;
    min-width: 0;
  }

  .brand-logo {
    width: 50px;
    height: 50px;
  }

  .eyebrow {
    font-size: .46rem;
    letter-spacing: .10em;
  }

  .header-copy h1 {
    font-size: 1.55rem;
  }

  .header-copy p {
    margin-top: 4px;
    max-width: 210px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .61rem;
  }

  .icon-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
  }

  .icon-btn span {
    display: none;
  }

  .workspace {
    display: block;
    position: relative;
    padding: 0;
  }

  .map-wrap {
    position: absolute;
    inset: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-sidebar-btn {
    display: grid;
    place-items: center;
    position: absolute;
    z-index: 1000;
    top: 10px;
    left: 10px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .38);
    border-radius: 12px;
    color: #fff;
    background: rgba(87, 16, 31, .96);
    box-shadow: 0 10px 25px rgba(59, 7, 18, .2);
  }

  .sidebar {
    position: absolute;
    z-index: 950;
    inset: 0 auto 0 0;
    width: min(355px, 91vw);
    padding: 66px 10px 20px;
    background: linear-gradient( 180deg, #fffafa, #f8edef );
    border-right: 1px solid var(--linea);
    box-shadow: 18px 0 40px rgba(59, 7, 18, .18);
    transform: translateX(-105%);
    transition: transform .23s ease;
    overscroll-behavior: contain;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: absolute;
    z-index: 900;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    background: rgba(35, 5, 12, .42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    transition: .2s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .panel {
    margin-bottom: 9px;
    padding: 12px;
    border-radius: 14px;
    box-shadow: 0 9px 22px rgba(59, 7, 18, .07);
  }

  input[type="text"],
  input[type="search"],
  input[type="number"] {
    min-height: 44px;
    font-size: 16px;
  }

  .primary-btn,
  .secondary-btn {
    min-height: 44px;
  }

  .leaflet-control-zoom {
    margin-top: 64px !important;
  }

  .map-status {
    left: 50%;
    bottom: 7px;
    transform: translateX(-50%);
    max-width: calc(100% - 18px);
    white-space: nowrap;
    font-size: .58rem;
  }

  .map-status span:last-child {
    display: none;
  }

  .leaflet-popup-content {
    width: min(280px, calc(100vw - 68px)) !important;
    max-height: 48vh;
    overflow-y: auto;
    margin: 12px;
  }

}

/* =========================================================
   CELULAR PEQUEÑO
   ========================================================= */

@media (max-width: 430px) {
  .topbar {
    height: 68px;
    min-height: 68px;
  }

  .eyebrow {
    font-size: .43rem;
  }

  .header-copy h1 {
    font-size: 1.38rem;
  }

  .header-copy p {
    max-width: 165px;
    font-size: .56rem;
  }

  .brand-logo {
    width: 46px;
    height: 46px;
  }

}

@media (max-width: 360px) {
  .header-copy p {
    display: none;
  }

  .eyebrow {
    font-size: .40rem;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

}
