/* Demo Maps a pantalla completa */
html:has(.amg-maps-play),
body:has(.amg-maps-play) {
  height: 100%;
  overflow: hidden;
}

body:has(.amg-maps-play) > header[data-header],
body:has(.amg-maps-play) > footer,
body:has(.amg-maps-play) #amg-bot,
body:has(.amg-maps-play) .amg-bot,
body:has(.amg-maps-play) .amg-bot-fab,
body:has(.amg-maps-play) .amg-bot-root,
body:has(.amg-maps-play) .policy-consent,
body:has(.amg-maps-play) #policy-consent {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body:has(.amg-maps-play) > main {
  padding: 0;
  margin: 0;
  height: 100dvh;
  max-width: none;
}

.amg-maps-play {
  position: relative;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    'top top'
    'side map';
  height: 100dvh;
  background: #0b0f1a;
  color: #e2e8f0;
}

.amg-maps-play-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-shrink: 0;
  min-height: 3.35rem;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(11 15 26 / 0.96);
  backdrop-filter: blur(12px);
  z-index: 30;
}

.amg-maps-play-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  position: relative;
  z-index: 32;
}

.amg-maps-play-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.05rem;
}

.amg-maps-play-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 0.12);
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}
.amg-maps-play-back:hover {
  color: #fff;
  border-color: rgb(255 255 255 / 0.25);
}

.amg-maps-play-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.amg-maps-play-hint {
  font-size: 0.68rem;
  color: #94a3b8;
}

.amg-maps-play-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 32;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: #5e36ff;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.amg-maps-play-cta:hover {
  background: #7e5cff;
}
.amg-maps-play-cta-short {
  display: none;
}

/* Escritorio: herramientas centradas en la misma fila que la topbar */
.amg-maps-play-tools {
  grid-area: top;
  align-self: center;
  justify-self: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: min(52vw, 42rem);
  padding: 0;
  border: 0;
  background: transparent;
  z-index: 31;
  pointer-events: none;
}
.amg-maps-play-tools .amg-maps-tool {
  pointer-events: auto;
}

.amg-maps-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 0.55rem;
  border: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(255 255 255 / 0.03);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.amg-maps-tool:hover {
  background: rgb(255 255 255 / 0.07);
  color: #fff;
}
.amg-maps-tool.is-active {
  background: rgb(94 54 255 / 0.25);
  border-color: rgb(126 92 255 / 0.55);
  color: #fff;
}

.amg-maps-play-body {
  grid-area: map;
  position: relative;
  z-index: 1;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.amg-maps-play-backdrop {
  display: none;
}

.amg-maps-play-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(17 23 39 / 0.96);
  z-index: 20;
}

.amg-maps-play-side-bar {
  display: none;
}

.amg-maps-play-search {
  position: relative;
  padding: 0.85rem 0.85rem 0.5rem;
}

.amg-maps-play-search-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.65rem;
  border: 1px solid rgb(255 255 255 / 0.12);
  background: #0b0f1a;
}

.amg-maps-play-search-row input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: #fff;
  font-size: 0.8125rem;
}

.amg-maps-play-search-btn {
  padding: 0.25rem 0.55rem;
  border-radius: 0.4rem;
  border: 0;
  background: #5e36ff;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.amg-maps-play-suggest {
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  top: calc(100% - 0.25rem);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border-radius: 0.65rem;
  border: 1px solid rgb(255 255 255 / 0.12);
  background: #111727;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.45);
  z-index: 40;
  max-height: 14rem;
  overflow: auto;
}

.amg-maps-play-suggest[hidden] {
  display: none !important;
}

.amg-maps-play-suggest button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: #e2e8f0;
  font-size: 0.78rem;
  cursor: pointer;
}
.amg-maps-play-suggest button:hover {
  background: rgb(255 255 255 / 0.06);
}

.amg-maps-play-side-head {
  padding: 0.5rem 0.95rem 0.65rem;
}
.amg-maps-play-side-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}
.amg-maps-play-side-head p {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: #94a3b8;
}

.amg-maps-play-list {
  list-style: none;
  margin: 0;
  padding: 0 0.55rem 0.55rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.amg-maps-play-company {
  display: flex;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.55rem;
  border: 0;
  border-radius: 0.65rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.amg-maps-play-company:hover,
.amg-maps-play-company.is-active {
  background: rgb(255 255 255 / 0.06);
}
.amg-maps-play-company.is-active {
  box-shadow: inset 0 0 0 1px rgb(126 92 255 / 0.45);
}

.amg-maps-play-company-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  margin-top: 0.35rem;
  flex-shrink: 0;
  background: #5e36ff;
}
.amg-maps-play-company-dot[data-tone='teal'] { background: #10b981; }
.amg-maps-play-company-dot[data-tone='amber'] { background: #f59e0b; }
.amg-maps-play-company-dot[data-tone='rose'] { background: #f43f5e; }
.amg-maps-play-company-dot[data-tone='sky'] { background: #0ea5e9; }
.amg-maps-play-company-dot[data-tone='slate'] { background: #64748b; }
.amg-maps-play-company-dot[data-tone='purple'] { background: #5e36ff; }

.amg-maps-play-company-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.amg-maps-play-company-name {
  font-size: 0.84rem;
  font-weight: 650;
  color: #fff;
}
.amg-maps-play-company-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  line-height: 1.35;
}

.amg-maps-play-status {
  padding: 0.7rem 0.9rem;
  border-top: 1px solid rgb(255 255 255 / 0.08);
  font-size: 0.72rem;
  color: #94a3b8;
  background: rgb(0 0 0 / 0.2);
}

.amg-maps-play-map-wrap {
  position: relative;
  z-index: 1;
  isolation: isolate;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
}

.amg-maps-play-map {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #0b0f1a;
}

/* Control de capas: icono SVG propio (CSP bloqueaba layers.png de unpkg) */
.amg-maps-play .leaflet-control-layers {
  border: 1px solid rgb(255 255 255 / 0.14) !important;
  border-radius: 0.65rem !important;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.35) !important;
  overflow: hidden;
}
.amg-maps-play .leaflet-control-layers-toggle {
  width: 36px !important;
  height: 36px !important;
  background-color: #111727 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23e2e8f0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12 2 2 7 12 12 22 7 12 2'/%3E%3Cpolyline points='2 17 12 22 22 17'/%3E%3Cpolyline points='2 12 12 17 22 12'/%3E%3C/svg%3E") !important;
  background-size: 20px 20px !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}
.amg-maps-play .leaflet-control-layers-expanded {
  padding: 0.55rem 0.65rem !important;
  background: #111727 !important;
  color: #e2e8f0;
}
.amg-maps-play .leaflet-control-layers label {
  color: #e2e8f0;
}

.amg-maps-play-toggle-side {
  display: none;
}

.amg-maps-tool-list {
  display: none;
}

.amg-maps-play-toggle-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #5e36ff;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
}

.amg-maps-play-side-handle {
  display: none;
}

.amg-maps-play-side-bar-row {
  display: contents;
}

.amg-maps-play-side-title {
  font-size: inherit;
  font-weight: inherit;
}

.amg-maps-play-side-count {
  display: none;
}

.amg-maps-popup {
  min-width: 180px;
  max-width: min(280px, 78vw);
  color: #e2e8f0;
}
.amg-maps-popup h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff !important;
}
.amg-maps-popup .sector {
  margin: 0.2rem 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #c4b5fd !important;
}
.amg-maps-popup p {
  margin: 0.2rem 0;
  font-size: 0.8rem;
  color: #cbd5e1 !important;
  line-height: 1.4;
  font-weight: 500;
}
.amg-maps-popup p strong {
  color: #f8fafc !important;
  font-weight: 700;
}
.amg-maps-popup .notes {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgb(255 255 255 / 0.12);
  color: #94a3b8 !important;
}

.amg-maps-play .leaflet-popup-content-wrapper {
  background: #111727 !important;
  color: #e2e8f0 !important;
  border: 1px solid rgb(255 255 255 / 0.14);
}
.amg-maps-play .leaflet-popup-tip {
  background: #111727 !important;
}
.amg-maps-play .leaflet-popup-close-button {
  color: #e2e8f0 !important;
  opacity: 0.85;
}
.amg-maps-play .leaflet-popup-close-button:hover {
  color: #fff !important;
  opacity: 1;
}

html[data-mode='light'] .amg-maps-play .amg-maps-popup h3,
html.amg-mode-light .amg-maps-play .amg-maps-popup h3 {
  color: #fff !important;
}
html[data-mode='light'] .amg-maps-play .amg-maps-popup .sector,
html.amg-mode-light .amg-maps-play .amg-maps-popup .sector {
  color: #ddd6fe !important;
}
html[data-mode='light'] .amg-maps-play .amg-maps-popup p,
html.amg-mode-light .amg-maps-play .amg-maps-popup p {
  color: #e2e8f0 !important;
}
html[data-mode='light'] .amg-maps-play .amg-maps-popup p strong,
html.amg-mode-light .amg-maps-play .amg-maps-popup p strong {
  color: #fff !important;
}
html[data-mode='light'] .amg-maps-play .amg-maps-popup .notes,
html.amg-mode-light .amg-maps-play .amg-maps-popup .notes {
  color: #cbd5e1 !important;
  border-top-color: rgb(255 255 255 / 0.16);
}

/* —— Móvil / tablet —— */
@media (max-width: 1023px) {
  .amg-maps-play-top {
    padding: 0.45rem 0.6rem;
    gap: 0.5rem;
  }

  .amg-maps-play-back span,
  .amg-maps-play-hint {
    display: none;
  }

  .amg-maps-play-back {
    padding: 0.45rem;
  }

  .amg-maps-play-title {
    font-size: 0.82rem;
  }

  .amg-maps-play-cta {
    padding: 0.42rem 0.7rem;
    font-size: 0.72rem;
  }
  .amg-maps-play-cta-full {
    display: none;
  }
  .amg-maps-play-cta-short {
    display: inline;
  }

  .amg-maps-play {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    grid-template-rows: none;
    grid-template-areas: none;
  }

  .amg-maps-play-top {
    order: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 0;
  }

  .amg-maps-play-body {
    order: 2;
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    z-index: 1;
    padding-bottom: 0;
  }

  .amg-maps-play-tools {
    order: 3;
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    align-self: stretch;
    justify-self: stretch;
    width: auto;
    max-width: none;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
    gap: 0.3rem 0.25rem;
    padding: 0.45rem 0.4rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-top: 1px solid rgb(255 255 255 / 0.1);
    background: rgb(11 15 26 / 0.98);
    z-index: 40;
    pointer-events: auto;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .amg-maps-play-backdrop {
    order: 4;
  }

  .amg-maps-play-side {
    order: 5;
  }

  .amg-maps-tool-list {
    display: inline-flex;
    color: #e9e3ff;
    border-color: rgb(94 54 255 / 0.55);
    background: rgb(94 54 255 / 0.22);
  }
  .amg-maps-tool-list.is-active,
  .amg-maps-tool-list[aria-expanded='true'] {
    background: #5e36ff;
    border-color: transparent;
    color: #fff;
  }

  .amg-maps-play.is-list-open .amg-maps-play-tools {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
  }

  .amg-maps-play-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9000;
    border: 0;
    margin: 0;
    padding: 0;
    background: rgb(0 0 0 / 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .amg-maps-play-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .amg-maps-play-side {
    position: fixed;
    inset: 0;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    height: 100dvh;
    max-height: none;
    transform: translateY(105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: none;
    border: 0;
    border-radius: 0;
    z-index: 9500;
    background: #111727;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .amg-maps-play-side.is-open {
    transform: translateY(0);
  }

  .amg-maps-play-side-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.65rem 0.9rem 0.75rem;
    border-bottom: 1px solid rgb(255 255 255 / 0.08);
    flex-shrink: 0;
  }

  .amg-maps-play-side-handle {
    display: none;
  }

  .amg-maps-play-side-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .amg-maps-play-side-title {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
  }

  .amg-maps-play-side-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgb(94 54 255 / 0.35);
    color: #e9e3ff;
    font-size: 0.72rem;
    font-weight: 700;
  }

  .amg-maps-play-side-close {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 0.55rem;
    border: 1px solid rgb(255 255 255 / 0.12);
    background: rgb(255 255 255 / 0.05);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .amg-maps-play-side-head {
    display: none;
  }

  .amg-maps-play-search {
    flex-shrink: 0;
    padding: 0.7rem 0.85rem 0.45rem;
  }

  .amg-maps-play-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.75rem;
  }

  .amg-maps-play-status {
    flex-shrink: 0;
  }

  .amg-maps-tool {
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
    min-height: 3.1rem;
    padding: 0.35rem 0.15rem;
    border-radius: 0.55rem;
    font-size: 0.58rem;
    line-height: 1.1;
  }
  .amg-maps-tool span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .amg-maps-play .leaflet-top.leaflet-left {
    top: 0.7rem;
  }
  .amg-maps-play .leaflet-top.leaflet-right {
    top: 0.65rem;
    right: 0.55rem;
  }
  .amg-maps-play .leaflet-control-layers {
    max-width: min(72vw, 220px);
  }
  .amg-maps-play .leaflet-control-layers-expanded {
    max-height: min(42vh, 280px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.78rem;
  }
  .amg-maps-play .leaflet-bottom.leaflet-left {
    bottom: 0.2rem;
    left: 0.35rem;
  }
  .amg-maps-play .leaflet-bottom.leaflet-right {
    bottom: 0.15rem;
    right: 0.15rem;
  }
  .amg-maps-play .leaflet-control-attribution {
    max-width: 50vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .amg-maps-play .leaflet-popup-content {
    margin: 0.55rem 0.7rem !important;
  }
}

@media (max-width: 380px) {
  .amg-maps-tool span:not(.amg-maps-play-toggle-count) {
    display: none;
  }
  .amg-maps-tool {
    min-height: 2.7rem;
  }
  .amg-maps-tool-list .amg-maps-play-toggle-count {
    display: inline-flex;
  }
}

html[data-mode='light'] .amg-maps-play,
html.amg-mode-light .amg-maps-play {
  background: #f8fafc;
  color: #0f172a;
}
html[data-mode='light'] .amg-maps-play-top,
html[data-mode='light'] .amg-maps-play-side,
html[data-mode='light'] .amg-maps-play-tools,
html.amg-mode-light .amg-maps-play-top,
html.amg-mode-light .amg-maps-play-side,
html.amg-mode-light .amg-maps-play-tools {
  background: #fff;
  border-color: #e2e8f0;
}
html[data-mode='light'] .amg-maps-play-title,
html[data-mode='light'] .amg-maps-play-company-name,
html[data-mode='light'] .amg-maps-play-side-bar,
html.amg-mode-light .amg-maps-play-title,
html.amg-mode-light .amg-maps-play-company-name,
html.amg-mode-light .amg-maps-play-side-bar {
  color: #0f172a;
}
html[data-mode='light'] .amg-maps-play-search-row,
html[data-mode='light'] .amg-maps-tool,
html.amg-mode-light .amg-maps-play-search-row,
html.amg-mode-light .amg-maps-tool {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #334155;
}
html[data-mode='light'] .amg-maps-play-search-row input,
html.amg-mode-light .amg-maps-play-search-row input {
  color: #0f172a;
}
html[data-mode='light'] .amg-maps-tool-list,
html.amg-mode-light .amg-maps-tool-list {
  background: rgb(94 54 255 / 0.12);
  border-color: rgb(94 54 255 / 0.4);
  color: #4c1d95;
}
