/* Selector accesible de apariencia. Los colores operativos conservan su significado. */
.theme-menu {
  position: relative;
}

.theme-menu > summary {
  list-style: none;
}

.theme-menu > summary::-webkit-details-marker {
  display: none;
}

.theme-menu-trigger {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--canvas);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.theme-menu-trigger:focus-visible,
.theme-option:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.theme-current-icon {
  font-size: 21px;
  line-height: 1;
}

.top-actions .theme-trigger-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.theme-menu-panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(320px, calc(100vw - 24px));
  gap: 5px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.theme-menu-panel > p {
  margin: 2px 5px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.theme-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 22px;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.theme-option:hover {
  background: var(--canvas);
}

.theme-option[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.theme-option > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.theme-option strong {
  font-size: 13px;
}

.theme-option small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-option i {
  visibility: hidden;
  color: var(--brand);
  font-size: 18px;
  font-style: normal;
  font-weight: 900;
}

.theme-option[aria-pressed="true"] i {
  visibility: visible;
}

.theme-swatch {
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px var(--paper);
}

.swatch-system { background: linear-gradient(135deg, #f4f7f6 50%, #172321 50%); }
.swatch-light { background: #0e5c5a; }
.swatch-dark { background: #58d0c4; box-shadow: inset 0 0 0 5px #172321; }
.swatch-mediterranean { background: linear-gradient(135deg, #087f8c 50%, #e8d8b7 50%); }
.swatch-contrast { background: #ffe600; box-shadow: inset 0 0 0 5px #000; }

.theme-save-status {
  min-height: 16px;
  padding: 2px 5px 0;
  color: var(--muted);
  font-size: 11px;
}

.login-theme-menu {
  margin: -8px 0 22px;
}

.login-theme-menu .theme-menu-trigger {
  width: 100%;
  border-color: var(--line);
  border-radius: 11px;
  background: var(--canvas);
}

.login-theme-menu .theme-menu-panel {
  right: 0;
  left: 0;
  width: 100%;
}

/* Mediterráneo cambia la identidad visual, no los colores de estado. */
html[data-theme-choice="mediterranean"] {
  --ink: #123445;
  --muted: #64777c;
  --line: #d6ded8;
  --paper: #fffdf7;
  --canvas: #f3efe4;
  --brand: #087f8c;
  --brand-2: #075985;
  --brand-soft: #dceff0;
  --shadow: 0 9px 28px rgba(7, 89, 133, .11);
  color-scheme: light;
}

html[data-theme-choice="mediterranean"] body {
  background: var(--canvas);
}

html[data-theme-choice="mediterranean"] .topbar,
html[data-theme-choice="mediterranean"] .user-menu > div,
html[data-theme-choice="mediterranean"] .panel,
html[data-theme-choice="mediterranean"] .login-card,
html[data-theme-choice="mediterranean"] .mobile-nav,
html[data-theme-choice="mediterranean"] .theme-menu-panel {
  background: var(--paper);
}

html[data-theme-choice="mediterranean"] input,
html[data-theme-choice="mediterranean"] select,
html[data-theme-choice="mediterranean"] textarea {
  background-color: var(--paper);
  color: var(--ink);
}

/* Alto contraste parte del modo oscuro y eleva bordes y foco. */
html[data-theme-choice="contrast"] {
  --ink: #fff;
  --muted: #e5e5e5;
  --line: #fff;
  --paper: #000;
  --canvas: #000;
  --brand: #00e5ff;
  --brand-2: #7ff3ff;
  --brand-soft: #003b43;
  --shadow: 0 0 0 2px #fff;
  color-scheme: dark;
}

html[data-theme-choice="contrast"] :focus-visible {
  outline: 4px solid #ffe600 !important;
  outline-offset: 3px;
}

html[data-theme-choice="contrast"] .button,
html[data-theme-choice="contrast"] .panel,
html[data-theme-choice="contrast"] .metric-card,
html[data-theme-choice="contrast"] .apartment-card,
html[data-theme-choice="contrast"] .cleaning-card,
html[data-theme-choice="contrast"] .incident-card,
html[data-theme-choice="contrast"] .parking-card {
  border-width: 2px;
}

@media (max-width: 680px) {
  .theme-menu-panel {
    position: fixed;
    top: 66px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100dvh - 86px);
    overflow-y: auto;
  }

  .login-theme-menu .theme-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    max-height: min(440px, calc(100dvh - 150px));
  }
}
