:root,
.calcite-mode-dark {
  /* ── Colores de marca de la aplicación ─────────────────────────────────── */
  /* Modificar estos valores (o sobreescribirlos desde JS) para cambiar      */
  /* el color principal en toda la interfaz.                                 */
  --app-color-brand: #d53c3d;
  --app-color-brand-hover: #be2d2e;
  --app-color-brand-press: #a52324;

  /* Variables de Calcite apuntan a las propias de la app */
  --calcite-color-brand: var(--app-color-brand);
  --calcite-color-brand-hover: var(--app-color-brand-hover);
  --calcite-color-brand-press: var(--app-color-brand-press);
}

.tool-panel {
  padding: 0.5rem;
  background-color: var(--calcite-color-foreground-1);
}

.tool-panel arcgis-weather {
  display: block;
  width: 100%;
}

.button-box {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

.input-button {
  display: flex;
  & calcite-input-text {
    width: 100%;
    flex-grow: 1;
  }
  & calcite-button {
    flex-shrink: 1;
  }
}

.grid-calcite {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 1rem;
}

#action-bar-end {
  min-width: 200px;
  height: 100%;
  overflow-y: auto;
}

/* Oculta grupos sin acciones visibles (y con ello su título interno).
   Se excluyen los grupos con slot="actions-end" (ej: botón de ayuda), que siempre son visibles. */
#action-bar-end calcite-action-group:not([slot='actions-end']):not(:has(calcite-action:not([hidden]))) {
  display: none;
}

#action-bar-end .action-group-title {
  display: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--calcite-color-text-3);
  padding: 0.6rem 0.75rem 0.25rem;
}

#action-bar-end[expanded] .action-group-title,
#action-bar-end[expanded='true'] .action-group-title {
  display: block;
}

#shell-panel-end {
  --calcite-color-focus: transparent;
  --calcite-ui-focus-color: transparent;
  --calcite-color-background: var(--calcite-color-foreground-1);
}

calcite-navigation,
.theme-switcher,
#mapEl,
#mapEl arcgis-zoom,
#mapEl arcgis-navigation-toggle,
#mapEl arcgis-compass,
#mapEl arcgis-basemap-gallery,
#mapEl arcgis-basemap-gallery-item {
  --calcite-color-focus: transparent;
  --calcite-ui-focus-color: transparent;
  --arcgis-ui-focus-color: transparent;
  --calcite-color-brand: transparent;
}

#mapEl arcgis-search {
  --calcite-color-brand: var(--calcite-color-border-input);
  --calcite-border-width-md: 0px;
}

#mapEl {
  --arcgis-internal-view-outline-color: transparent;
  --arcgis-internal-view-outline: none;
  --arcgis-internal-view-color-focus: transparent;
}

#action-bar-end calcite-action[active] {
  background-color: color-mix(in srgb, var(--app-color-brand) 12%, transparent);
  border-radius: 8px;
  --calcite-action-text-color: var(--calcite-color-brand);
  --calcite-action-icon-color: var(--calcite-color-brand);
  box-shadow: none;
}

/* Indicador de panel lateral activo: línea izquierda sin mover el layout */
#action-bar-end calcite-action[data-ui-mode='panel'][active] {
  box-shadow: inset 3px 0 0 var(--calcite-color-brand);
  border-radius: 0 8px 8px 0;
}

#action-bar-end calcite-action:focus,
#action-bar-end calcite-action:focus-visible {
  outline: none;
}

calcite-tab-title[selected] {
  color: var(--calcite-color-brand);
  font-weight: 600;
  background-color: color-mix(in srgb, var(--app-color-brand) 12%, transparent);
  border-radius: 6px 6px 0 0;
  padding: 0.25rem 0.6rem;
}

#action-bar-end:not([expanded]) {
  min-width: unset;
}

.logo {
  height: 45px;
  margin: 0 2rem 0 1rem;
}

.theme-switcher {
  --calcite-switch-background-color-hover: var(--app-color-brand);
  --calcite-color-brand: var(--app-color-brand);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 2rem;
}

.input-container {
  display: flex;
  align-items: center;
  margin: 0.5rem 0;
}

.file-button {
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 5px 10px;
  cursor: pointer;
  text-overflow: ellipsis;
  overflow: hidden;
}

.app-title {
  font-weight: bold;
  font-size: 1.2rem;
  padding: 0 1rem;
}

#app-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.logos-footer {
  background-color: var(--calcite-color-foreground-1);
  border-top: 1px solid var(--calcite-color-border-3);
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
}

/* Separación de la alerta global respecto al borde (según su placement) */
#app-alert {
  --calcite-alert-offset-size: 5rem;
}

.logos-footer img {
  height: 50px;
  width: auto;
  object-fit: contain;
}

/* Floating draggable widgets */
.floating-widget {
  position: fixed;
  width: 360px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.22),
    0 2px 8px rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
}

.floating-widget calcite-panel {
  flex: 1;
  max-height: 80vh;
  overflow-y: auto;
  min-height: 0;
  --calcite-color-background: var(--calcite-color-foreground-1);
  --calcite-color-focus: transparent;
  --calcite-ui-focus-color: transparent;
  --arcgis-ui-focus-color: transparent;
}

.floating-widget:has(.floating-widget-resize[style]) calcite-panel,
.floating-widget[style*='height'] calcite-panel {
  max-height: none;
}

.floating-widget-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: se-resize;
  z-index: 10;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cpath d='M9 1L1 9M9 5L5 9M9 9' stroke='%23fff' stroke-width='1.5' stroke-linecap='round' opacity='0.7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.floating-widget-handle {
  height: 36px;
  min-height: 36px;
  background: var(--calcite-color-brand);
  cursor: grab;
  flex-shrink: 0;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem 0 0.875rem;
  user-select: none;
}

.floating-widget-handle:hover {
  filter: brightness(1.08);
}

.floating-widget-handle.is-dragging {
  cursor: grabbing;
}

.floating-widget-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.floating-widget-handle-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.floating-widget-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  transition:
    background 0.15s,
    color 0.15s;
}

.floating-widget-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* Search Styles */
#panel-search .tool-panel {
  padding: 0.75rem;
}

#panel-search calcite-tabs {
  margin-bottom: 0.5rem;
}

#panel-search .search-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

#panel-search .button-box {
  margin: 0.25rem 0 0.5rem;
}

#panel-search .results-box {
  margin-top: 0.75rem;
}

#panel-search .results-box h3 {
  display: flex;
  align-items: center;
  margin: 0 0 0.5rem;
  & span {
    flex-grow: 1;
  }
}

/* Measure Styles */
#panel-measure .tool-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#panel-measure .results-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#panel-measure .results-box > * {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* TOC Styles */
#panel-toc arcgis-layer-list:not([reference-element]) {
  display: none;
}
#panel-toc arcgis-layer-list[reference-element] ~ calcite-loader {
  display: none;
}

/* POIs Styles */
.poi-detail-link {
  color: var(--app-color-brand);  
  /* & :hover {
    color: var(--app-color-brand-hover);
  }
  & :active {
    color: var(--app-color-brand-press);
  } */
}
/* 
#panel-pois .poi-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

#panel-pois .poi-loading {
  display: flex;
  justify-content: center;
}

#panel-pois .poi-detail-view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#panel-pois .poi-detail-name {
  margin: 0;
  font-size: 1rem;
}

#panel-pois .poi-detail-description {
  margin: 0;
  font-size: 0.875rem;
}

#panel-pois .poi-detail-qr img {
  display: block;
  margin: 0 auto;
  width: 180px;
  height: 180px;
} */

/* Weather Styles */
#panel-weather .tool-panel,
.floating-widget:has(#panel-weather) .tool-panel {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

arcgis-weather,
arcgis-daylight {
  --calcite-color-focus: transparent;
  --calcite-ui-focus-color: transparent;
}

.floating-widget:has(#panel-weather) arcgis-weather,
.floating-widget:has(#panel-weather) arcgis-daylight {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* ── Help: spotlight overlay ──────────────────────────────────────────────── */
#help-spotlight-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: all;
}

.help-spotlight-piece {
  position: fixed;
  background: rgba(0, 0, 0, 0.72);
  transition: all 0.2s ease;
}

/* ── Help: popover de paso del tour ──────────────────────────────────────── */
#help-popover {
  position: fixed;
  z-index: 9995;
  width: 300px;
  background: var(--calcite-color-foreground-1);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
  pointer-events: all;
}

#help-popover .help-step-counter {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--calcite-color-text-3);
  margin-bottom: 0.25rem;
}

#help-popover .help-step-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--calcite-color-text-1);
  margin: 0 0 0.5rem;
}

#help-popover .help-step-body {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--calcite-color-text-2);
  margin-bottom: 1rem;
}

#help-popover .help-step-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* Flechas del popover */
.help-popover-arrow {
  position: absolute;
  width: 0;
  height: 0;
}

.help-popover-arrow--right {
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid var(--calcite-color-foreground-1);
}

.help-popover-arrow--left {
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid var(--calcite-color-foreground-1);
}

.help-popover-arrow--bottom {
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--calcite-color-foreground-1);
}

/* ── Help: modal de bienvenida / cierre ──────────────────────────────────── */
#help-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

#help-modal-overlay[hidden] {
  display: none;
}

#help-modal {
  background: var(--calcite-color-foreground-1);
  border-radius: 12px;
  padding: 2rem;
  width: min(480px, calc(100vw - 2rem));
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.32);
  pointer-events: all;
}

.help-modal-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--calcite-color-brand);
}

.help-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--calcite-color-text-1);
  margin: 0 0 0.75rem;
  text-align: center;
}

.help-modal-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--calcite-color-text-2);
  margin: 0 0 0.5rem;
  text-align: center;
}

.help-modal-subtitle {
  font-size: 0.875rem;
  color: var(--calcite-color-text-3);
  text-align: center;
  margin: 0 0 1.5rem;
}

/* Suprime outlines de Calcite dentro de los contenedores de ayuda */
#help-modal,
#help-skip-modal,
#help-popover {
  --calcite-color-focus: transparent;
  --calcite-ui-focus-color: transparent;
}

.help-modal-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--calcite-color-text-2);
  margin-bottom: 1.25rem;
  cursor: pointer;
  --calcite-label-margin-bottom: 0;
}

.help-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Confirmación inline al omitir el tour */
.help-skip-confirm-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--calcite-color-text-2);
  flex: 1;
  cursor: pointer;
}

/* ── Help: modal de confirmación al omitir ───────────────────────────────── */
#help-skip-overlay {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

#help-skip-overlay[hidden] {
  display: none;
}

#help-skip-modal {
  background: var(--calcite-color-foreground-1);
  border-radius: 12px;
  padding: 1.5rem;
  width: min(380px, calc(100vw - 2rem));
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.32);
}

/* ── Help: panel flotante de ayuda por widget ────────────────────────────── */
#help-widget-float {
  position: fixed;
  z-index: 9000;
  width: 360px;
  min-width: 240px;
  min-height: 120px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
  background: var(--calcite-color-foreground-1);
  top: 80px;
  right: 80px;
}

#help-widget-float[hidden] {
  display: none;
}

#help-widget-float-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.625rem 0 0.875rem;
  height: 36px;
  min-height: 36px;
  background: var(--calcite-color-brand);
  cursor: grab;
  user-select: none;
}

#help-widget-float-handle.is-dragging {
  cursor: grabbing;
}

#help-widget-float-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#help-widget-float-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 0.5rem;
  flex-shrink: 0;
  transition: color 0.15s;
}

#help-widget-float-close:hover {
  color: #fff;
}

#help-widget-float-body {
  padding: 0.875rem 1rem;
  overflow-y: auto;
  flex: 1;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--calcite-color-text-2);
}

#help-widget-float-body p {
  margin: 0 0 0.75rem;
}

#help-widget-float-body p:last-child {
  margin-bottom: 0;
}

#help-widget-float-body h4 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--calcite-color-text-1);
  margin: 1rem 0 0.35rem;
}

#help-widget-float-body video,
#help-widget-float-body iframe {
  display: block;
  width: 100%;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

/* Resize handle (inyectado por JS, igual que .floating-widget-resize) */
#help-widget-float .floating-widget-resize {
  bottom: 0;
  right: 0;
}

/* Cartelito que sale cuando pulsas en un POI */
.floating-banner {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--app-color-brand-press);
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  opacity: 1;
  transition: opacity 1s ease;
  cursor:pointer;
}

.floating-banner.fade-out {
  opacity: 0;
}