/* =========================================================
   IntegridadQHSE — Theme Toggle / Corporate Tech
   Componente global, independiente de los colores de producto.
   ========================================================= */

.theme-toggle {
  --tt-night: #071310;
  --tt-surface: #10241f;
  --tt-primary: #0f766e;
  --tt-tech: #14b8a6;
  --tt-accent: #f59e0b;
  --tt-white: #ffffff;

  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99999;

  min-width: 154px;
  height: 46px;
  padding: 0 16px;

  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;

  background:
    linear-gradient(
      105deg,
      transparent 0%,
      transparent 43%,
      rgba(255, 255, 255, 0.00) 46%,
      rgba(255, 255, 255, 0.24) 50%,
      rgba(255, 255, 255, 0.00) 54%,
      transparent 57%,
      transparent 100%
    ) -190px 0 / 92px 100% no-repeat,
    linear-gradient(
      135deg,
      rgba(7, 19, 16, 0.97) 0%,
      rgba(16, 36, 31, 0.95) 100%
    );

  color: var(--tt-white) !important;
  -webkit-text-fill-color: var(--tt-white) !important;

  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);

  backdrop-filter: blur(14px) saturate(1.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);

  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.01em;

  isolation: isolate;

  transition:
    transform 0.20s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease,
    background-position 0.75s cubic-bezier(.22,.61,.36,1);
}

/* Borde energético IntegridadQHSE: teal → turquesa → ámbar */
.theme-toggle::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;

  padding: 1.5px;
  border-radius: inherit;

  background:
    linear-gradient(
      110deg,
      var(--tt-primary) 0%,
      var(--tt-tech) 36%,
      #7eead8 52%,
      var(--tt-accent) 72%,
      var(--tt-primary) 100%
    );
  background-size: 240% 100%;

  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;

  opacity: 0.78;
  filter:
    drop-shadow(0 0 5px rgba(20, 184, 166, 0.34))
    drop-shadow(0 0 4px rgba(245, 158, 11, 0.16));

  pointer-events: none;
  animation: iq-tech-border-flow 7s linear infinite;
}

/* Firma mínima teal + amber */
.theme-toggle::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 48px;
  height: 2px;
  transform: translateX(-50%);
  border-radius: 99px;
  background:
    linear-gradient(
      90deg,
      var(--tt-primary) 0%,
      var(--tt-tech) 58%,
      var(--tt-accent) 100%
    );
  opacity: 0.52;
  pointer-events: none;
  box-shadow: 0 0 7px rgba(20, 184, 166, 0.20);
}

.theme-toggle:hover {
  transform: translateY(-2px);
  border-color: rgba(94, 234, 212, 0.40);

  background-position:
    calc(100% + 190px) 0,
    0 0;

  box-shadow:
    0 16px 38px rgba(0, 0, 0, 0.34),
    0 0 18px rgba(20, 184, 166, 0.15),
    0 0 12px rgba(245, 158, 11, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

.theme-toggle:hover::before {
  opacity: 1;
  filter:
    drop-shadow(0 0 7px rgba(20, 184, 166, 0.46))
    drop-shadow(0 0 5px rgba(245, 158, 11, 0.23));
}

.theme-toggle:active {
  transform: translateY(0) scale(0.985);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.30),
    0 0 0 3px rgba(20, 184, 166, 0.30),
    0 0 20px rgba(20, 184, 166, 0.17);
}

/* ========================= NÚCLEO ========================= */

.theme-toggle__icons {
  position: relative;
  width: 29px;
  height: 29px;
  border-radius: 999px;

  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.34), transparent 28%),
    linear-gradient(
      135deg,
      var(--tt-primary) 0%,
      var(--tt-tech) 58%,
      var(--tt-accent) 100%
    );

  color: var(--tt-white) !important;
  -webkit-text-fill-color: var(--tt-white) !important;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;

  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 10px rgba(20, 184, 166, 0.34),
    inset 0 1px 2px rgba(255, 255, 255, 0.18);

  transition:
    transform 0.38s cubic-bezier(.2,.8,.2,1),
    box-shadow 0.28s ease;
}

.theme-toggle:hover .theme-toggle__icons {
  transform: rotate(10deg) scale(1.05);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.24),
    0 0 14px rgba(20, 184, 166, 0.48),
    0 0 8px rgba(245, 158, 11, 0.18),
    inset 0 1px 2px rgba(255, 255, 255, 0.22);
}

.theme-toggle__icon {
  width: 16px;
  height: 16px;
  display: none;
  color: var(--tt-white) !important;
  fill: currentColor;
  stroke: currentColor;
}

body[data-theme="light"] .theme-toggle__icon--sun,
body[data-theme="dark"] .theme-toggle__icon--moon {
  display: block;
  animation: iq-theme-icon-in 0.46s cubic-bezier(.2,.8,.2,1);
}

/* ========================= TEXTO ========================= */

.theme-toggle__label,
body[data-theme="light"] .theme-toggle__label,
body[data-theme="dark"] .theme-toggle__label,
body[data-theme="light"] .theme-toggle span,
body[data-theme="dark"] .theme-toggle span {
  color: var(--tt-white) !important;
  -webkit-text-fill-color: var(--tt-white) !important;
}

.theme-toggle__label {
  position: relative;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.28);
}

.theme-toggle svg,
.theme-toggle svg *,
body[data-theme="light"] .theme-toggle svg,
body[data-theme="light"] .theme-toggle svg * {
  color: var(--tt-white) !important;
  fill: currentColor;
  stroke: currentColor;
}

/* ========================= ANIMACIONES ========================= */

@keyframes iq-tech-border-flow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 240% 50%; }
}

@keyframes iq-theme-icon-in {
  0% {
    opacity: 0;
    transform: rotate(-160deg) scale(0.62);
    filter: blur(2px);
  }
  65% {
    opacity: 1;
    transform: rotate(12deg) scale(1.10);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    filter: blur(0);
  }
}

/* ========================= RESPONSIVE ========================= */

@media (max-width: 600px) {
  .theme-toggle {
    right: 12px;
    bottom: 12px;
    min-width: 132px;
    height: 42px;
    padding: 0 12px;
    gap: 8px;
    font-size: 0.84rem;
  }

  .theme-toggle__icons {
    width: 26px;
    height: 26px;
  }

  .theme-toggle__icon {
    width: 15px;
    height: 15px;
  }

  .theme-toggle::after {
    width: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle__icons {
    transition: none;
  }

  .theme-toggle::before,
  body[data-theme="light"] .theme-toggle__icon--sun,
  body[data-theme="dark"] .theme-toggle__icon--moon {
    animation: none;
  }

  .theme-toggle:hover {
    background-position:
      -190px 0,
      0 0;
  }
}

/* =========================================================
   INTEGRACIÓN CON LA NAVBAR INTEGRIDADQHSE
   ========================================================= */

.theme-toggle,
body[data-theme="dark"] .theme-toggle {
  background:
    linear-gradient(
      105deg,
      transparent 0%,
      transparent 43%,
      rgba(255, 255, 255, 0.00) 46%,
      rgba(255, 255, 255, 0.22) 50%,
      rgba(255, 255, 255, 0.00) 54%,
      transparent 57%,
      transparent 100%
    ) -190px 0 / 92px 100% no-repeat,
    linear-gradient(135deg, #12211e 0%, #0f1b18 58%, #0a1412 100%) !important;

  border-color: rgba(94, 234, 212, 0.13) !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

body[data-theme="light"] .theme-toggle {
  background:
    linear-gradient(
      105deg,
      transparent 0%,
      transparent 43%,
      rgba(255, 255, 255, 0.00) 46%,
      rgba(255, 255, 255, 0.84) 50%,
      rgba(255, 255, 255, 0.00) 54%,
      transparent 57%,
      transparent 100%
    ) -190px 0 / 92px 100% no-repeat,
    linear-gradient(135deg, #f4f8f6 0%, #eaf1ee 58%, #dfe9e5 100%) !important;

  border-color: rgba(15, 118, 110, 0.13) !important;
  box-shadow:
    0 12px 28px rgba(15, 80, 70, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.84) !important;
}

/* En light, el label conserva contraste fuerte */
body[data-theme="light"] .theme-toggle__label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #15312a 0%, #0f1b18 100%);
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  box-shadow:
    0 4px 12px rgba(15, 80, 70, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

body[data-theme="dark"] .theme-toggle__label,
body:not([data-theme]) .theme-toggle__label {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.theme-toggle__icons {
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.34), transparent 28%),
    linear-gradient(135deg, #0f766e 0%, #14b8a6 62%, #f59e0b 100%) !important;
}

body[data-theme="light"] .theme-toggle:hover {
  border-color: rgba(15, 118, 110, 0.30) !important;
  box-shadow:
    0 15px 34px rgba(15, 80, 70, 0.16),
    0 0 16px rgba(20, 184, 166, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.90) !important;
}

body[data-theme="dark"] .theme-toggle:hover,
body:not([data-theme]) .theme-toggle:hover {
  border-color: rgba(20, 184, 166, 0.36) !important;
}

body[data-theme="light"] .theme-toggle span,
body[data-theme="light"] .theme-toggle__label,
body[data-theme="light"] .theme-toggle__icons,
body[data-theme="light"] .theme-toggle svg,
body[data-theme="light"] .theme-toggle svg * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
