/* SaaS Map — UI standalone Leaflet (F3b). Tokens de brv2-tokens.css */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body.saas-map {
  font-family: var(--brv2-font-family);
  font-size: var(--brv2-font-size-sm);
  line-height: var(--brv2-line-height);
  color: var(--brv2-color-text);
  background: var(--brv2-color-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.saas-map__toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--brv2-color-surface);
  border-bottom: 1px solid var(--brv2-color-border);
  box-shadow: var(--brv2-shadow-sm);
  z-index: 2;
}

#legacy-panel,
.saas-map__toolbar--legacy {
  display: none !important;
}

body.is-legacy-debug #legacy-panel:not([hidden]),
body.is-legacy-debug .saas-map__toolbar--legacy:not([hidden]) {
  display: flex !important;
}

.saas-map__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.saas-map__field label {
  font-size: var(--brv2-font-size-xs);
  font-weight: 600;
  color: var(--brv2-color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.saas-map__field input {
  appearance: none;
  border: 1px solid var(--brv2-color-border-strong);
  background: var(--brv2-color-surface);
  color: var(--brv2-color-text);
  font: inherit;
  font-size: var(--brv2-font-size-sm);
  padding: 0.45rem 0.65rem;
  min-height: var(--brv2-btn-height);
  border-radius: var(--brv2-radius-sm);
  min-width: 10rem;
}

.saas-map__field--grow {
  flex: 1 1 12rem;
}

.saas-map__field--grow input {
  width: 100%;
}

.saas-map__field input:focus {
  outline: none;
  border-color: var(--map-shell-accent);
  box-shadow: 0 0 0 2px rgba(var(--brv2-color-accent-rgb), 0.15);
}

.saas-map__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.saas-map__btn {
  appearance: none;
  border: 1px solid var(--brv2-color-border-strong);
  background: var(--brv2-color-surface);
  color: var(--brv2-color-text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  min-height: var(--brv2-btn-height);
  border-radius: var(--brv2-radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.saas-map__btn:hover:not(:disabled),
.saas-map__btn:focus-visible {
  background: var(--brv2-color-bg-muted);
  outline: none;
}

.saas-map__btn--primary {
  background: var(--map-shell-accent);
  border-color: var(--map-shell-accent-dark);
  color: #fff;
}

.saas-map__btn--primary:hover:not(:disabled),
.saas-map__btn--primary:focus-visible {
  background: var(--map-shell-accent-dark);
}

.saas-map__btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.saas-map__status {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--map-shell-muted);
}

.saas-map__status.is-loading {
  color: var(--brv2-color-info);
}

.saas-map__status.is-error {
  color: var(--brv2-color-danger);
}

.saas-map__status.is-ok {
  color: var(--brv2-color-ok);
}

.saas-map__layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .saas-map__layout {
    flex-direction: row;
  }
}

.saas-map__map-pane {
  flex: 1 1 60%;
  min-height: 45vh;
  position: relative;
  background: var(--brv2-color-map-pane);
}

.saas-map__map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.saas-map__map .leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
}

.saas-map__side {
  flex: 1 1 40%;
  min-height: 0;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  background: var(--brv2-color-surface);
  border-top: 1px solid var(--brv2-color-border);
  overflow: hidden;
}

@media (min-width: 768px) {
  .saas-map__side {
    max-height: none;
    max-width: 22rem;
    border-top: none;
    border-left: 1px solid var(--brv2-color-border);
  }
}

.saas-map__side-title {
  margin: 0;
  padding: 0.75rem 1rem 0.5rem;
  font-size: var(--brv2-font-size-md);
  font-weight: 600;
  border-bottom: 1px solid var(--brv2-color-border-soft);
}

.saas-map__stops {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
}

.saas-map__stops li {
  display: flex;
  gap: 0.55rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--brv2-color-border-row);
  font-size: var(--brv2-font-size-sm);
}

.saas-map__stop-num {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--map-shell-accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.saas-map__stop-body {
  min-width: 0;
  flex: 1 1 auto;
}

.saas-map__stop-body strong {
  display: block;
  font-size: var(--brv2-font-size-sm);
}

.saas-map__stop-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--brv2-font-size-xs);
  color: var(--brv2-color-text-subtle);
}

.saas-map__empty {
  margin: 0.75rem 1rem;
  padding: 0.75rem;
  font-size: var(--brv2-font-size-sm);
  color: var(--map-shell-muted);
  background: var(--brv2-color-bg-muted);
  border-radius: var(--brv2-radius-sm);
}

.saas-map__empty[hidden] {
  display: none;
}

.map-stop-icon {
  background: transparent;
  border: none;
}

.map-stop-pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
  border: 2px solid #fff;
}

.map-stop-pin--invalid {
  background: var(--brv2-color-danger) !important;
}

.map-stop-pin--highlight {
  border-color: #fef3c7 !important;
  border-width: 3px !important;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.45), 0 2px 8px rgba(15, 23, 42, 0.4);
  font-size: 0.8125rem;
}

.map-popup-badge {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: var(--brv2-radius-pill);
}

.map-popup-badge--danger {
  color: var(--brv2-color-danger-text);
  background: var(--brv2-color-danger-bg);
}

/* Manager embed */
.manager-panel--mapa .saas-map__layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.manager-panel--mapa .saas-map__side {
  max-height: 35vh;
}

@media (min-width: 768px) {
  .manager-panel--mapa .saas-map__side {
    max-height: none;
  }
}
