/* Modo escala de grises */
body.grayscale-mode {
  filter: grayscale(100%);
  -webkit-filter: grayscale(100%);
}

/* Modo alto contraste */
body.high-contrast-mode {
  background-color: #000000 !important;
  color: #ffffff !important;
}

body.high-contrast-mode *:not(.offcanvas-overlay):not(.offcanvas-overlay *) {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

body.high-contrast-mode a:not(.offcanvas-overlay):not(.offcanvas-overlay *),
body.high-contrast-mode a:not(.offcanvas-overlay):not(.offcanvas-overlay *):hover,
body.high-contrast-mode a:not(.offcanvas-overlay):not(.offcanvas-overlay *):focus {
  color: #ffff00 !important;
  text-decoration: underline !important;
}

body.high-contrast-mode button:not(.offcanvas-overlay):not(.offcanvas-overlay *),
body.high-contrast-mode .button:not(.offcanvas-overlay):not(.offcanvas-overlay *),
body.high-contrast-mode input:not(.offcanvas-overlay):not(.offcanvas-overlay *),
body.high-contrast-mode select:not(.offcanvas-overlay):not(.offcanvas-overlay *),
body.high-contrast-mode textarea:not(.offcanvas-overlay):not(.offcanvas-overlay *) {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
}

body.high-contrast-mode .offcanvas-overlay {
  background: rgba(0, 0, 0, 0.5) !important;
}

body.high-contrast-mode .offcanvas {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-right: 2px solid #ffffff !important;
}

body.high-contrast-mode .offcanvas-header {
  background-color: #333333 !important;
  color: #ffffff !important;
  border-bottom: 2px solid #ffffff !important;
}

body.high-contrast-mode .accessibility-menu-item {
  background-color: #333333 !important;
  color: #ffffff !important;
  border: 1px solid #ffffff !important;
}

body.high-contrast-mode .accessibility-menu-item:hover {
  background-color: #555555 !important;
}

/* Modo contraste negativo */
body.negative-contrast-mode {
  filter: invert(100%) hue-rotate(180deg) contrast(90%);
  -webkit-filter: invert(100%) hue-rotate(180deg) contrast(90%);
  background-color: #000 !important;
}

body.negative-contrast-mode img,
body.negative-contrast-mode video,
body.negative-contrast-mode iframe,
body.negative-contrast-mode canvas {
  filter: invert(100%) hue-rotate(180deg);
  -webkit-filter: invert(100%) hue-rotate(180deg);
}

body.negative-contrast-mode .offcanvas-overlay {
  filter: none !important;
  -webkit-filter: none !important;
  background: rgba(0, 0, 0, 0.5) !important;
}

body.negative-contrast-mode .offcanvas {
  filter: invert(100%) hue-rotate(180deg);
  -webkit-filter: invert(100%) hue-rotate(180deg);
}

/* Modo fondo claro */
body.light-background-mode {
  background-color: #ffffff !important;
  color: #000000 !important;
}

body.light-background-mode *:not(.offcanvas-overlay):not(.offcanvas-overlay *) {
  background-color: #ffffff !important;
  color: #000000 !important;
  border-color: #000000 !important;
}

body.light-background-mode .offcanvas-overlay {
  background: rgba(0, 0, 0, 0.5) !important;
}

/* Subrayar enlaces */
body.underline-links-mode a {
  text-decoration: underline !important;
}

/* Fuente legible */
body.readable-font-mode {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* Menú de accesibilidad */
.accessibility-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.accessibility-menu-item {
  cursor: pointer;
  padding: 0.5rem 1rem;
  background: #f0f0f0;
  border-radius: 4px;
  transition: background-color 0.3s;
  font-size: 0.9rem;
}

.accessibility-menu-item:hover {
  background: #e0e0e0;
}

/* Offcanvas */
.offcanvas-toggle {
  background-color: #40c6ff;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s;
  margin: 10px 0;
  position: fixed;
  top: 4px !important;
  left: 0;
  z-index: 5000;
}

@media (orientation: portrait) {
  .offcanvas-toggle {
    top: -3px !important;
  }
}

@media (orientation: landscape) {
  .offcanvas-toggle {
    top: -3px !important;
  }
}

.offcanvas-toggle:hover {
  background-color: #1e456b;
}

.offcanvas-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 999;
  pointer-events: none;
}

.offcanvas-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.offcanvas {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100%;
  background: white;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  transition: left 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
  font-size: 1rem;
}

.offcanvas.active {
  left: 0;
}

.offcanvas-header {
  padding: 1rem;
  background: white;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.offcanvas-header h4 {
  margin: 0;
  text-align: center;
  flex-grow: 1;
}

.offcanvas-close {
  background: red;
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 45px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s;
  z-index: 11;
}

.offcanvas-close:hover {
  color: #ffcc00;
}

.offcanvas-body {
  padding: 1.5rem;
}

.offcanvas-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.offcanvas-menu li {
  margin-bottom: 0.8rem;
}

body.offcanvas-open {
  overflow: visible;
  position: relative;
  height: auto;
}

.offcanvas,
.offcanvas-overlay {
  position: fixed;
}

@media (max-width: 768px) {
  .offcanvas {
    width: 250px;
  }

  .offcanvas-toggle {
    padding: 5px 7px;
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .offcanvas,
  .offcanvas-overlay {
    transition: none;
  }
}

.offcanvas-toggle:focus,
.offcanvas-close:focus,
.accessibility-menu-item:focus {
  outline: 2px solid #2a5783;
  outline-offset: 2px;
}
