/* ===========================================================
   Apparel KCI - Login Traccar  (v2)
   - Layout centrado: root (contenedor) + sidebar (logo) + tarjeta acrilica Fluent
   - Fondo animado: tela twill, prendas flotando, costuras corriendo y
     un riel de perchas que se balancea arriba
   =========================================================== */

:root {
  --kci-red: #d71920;
  --kci-logo: url("/Apparel_KCi_Logo.png"); /* cambia la ruta si el logo esta en otro lugar */
}

/* ===========================================================
   1) FONDO ANIMADO
   =========================================================== */

/* Base: tela twill oscura + resplandores rojos que respiran */
body {
  margin: 0;
  background-color: #0b0b0c !important;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(215, 25, 32, 0.50), transparent 45%),
    radial-gradient(circle at 85% 82%, rgba(215, 25, 32, 0.30), transparent 45%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 7px),
    linear-gradient(135deg, #0b0b0c, #1a1a1d) !important;
  background-size: 180% 180%, 160% 160%, auto, auto, auto !important;
  animation: kci-glow 22s ease-in-out infinite;
}

@keyframes kci-glow {
  0%   { background-position: 0% 0%, 100% 100%, 0 0, 0 0, 0 0; }
  50%  { background-position: 100% 60%, 0% 40%, 14px 14px, -14px 14px, 0 0; }
  100% { background-position: 0% 0%, 100% 100%, 0 0, 0 0, 0 0; }
}

/* Capa A: camisetas, perchas, botones y agujas a la deriva */
body::before {
  content: "";
  position: fixed;
  inset: -240px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.15;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240' fill='none' stroke='white' stroke-width='2' stroke-linejoin='round' stroke-linecap='round'><path d='M40 20 L52 14 Q60 24 68 14 L80 20 L96 36 L86 46 L78 40 L78 88 L42 88 L42 40 L34 46 L24 36 Z'/><path d='M170 44 L170 38 A5 5 0 1 0 165 33 M170 44 L200 62 L140 62 Z'/><circle cx='60' cy='180' r='12'/><circle cx='56' cy='177' r='1.6' fill='white'/><circle cx='64' cy='177' r='1.6' fill='white'/><circle cx='56' cy='183' r='1.6' fill='white'/><circle cx='64' cy='183' r='1.6' fill='white'/><path d='M150 205 Q168 170 196 160' stroke-dasharray='5 6'/><ellipse cx='198' cy='159' rx='2' ry='4' transform='rotate(40 198 159)'/></svg>");
  background-size: 240px 240px;
  animation: kci-drift 40s linear infinite;
}

/* Capa B: puntadas de costura corriendo (blanco y rojo) */
body::after {
  content: "";
  position: fixed;
  inset: -300px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.22;
  transform: rotate(-12deg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='150' viewBox='0 0 300 150' fill='none' stroke-width='2.5' stroke-linecap='round'><path d='M0 75 H300' stroke='white' stroke-dasharray='14 10'/><path d='M0 100 H300' stroke='rgb(215,25,32)' stroke-dasharray='6 12'/></svg>");
  background-size: 300px 150px;
  animation: kci-stitch 12s linear infinite;
}

/* Capa C: riel de perchas con prendas colgando que se balancea */
html::before {
  content: "";
  position: fixed;
  top: 0;
  left: -6%;
  width: 112%;
  height: 130px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='110' viewBox='0 0 400 110' fill='none' stroke='white' stroke-width='2' stroke-linejoin='round' stroke-linecap='round'><path d='M0 1 H400' stroke-width='3'/><path d='M100 1 V12 M100 12 L132 28 H68 Z'/><g transform='translate(40 12)'><path d='M40 20 L52 14 Q60 24 68 14 L80 20 L96 36 L86 46 L78 40 L78 88 L42 88 L42 40 L34 46 L24 36 Z'/></g><path d='M300 1 V12 M300 12 L324 24 H276 Z'/><path d='M278 24 H322 L326 100 H306 L300 58 L294 100 H274 Z' stroke='rgb(215,25,32)' stroke-width='2.5'/></svg>");
  background-repeat: repeat-x;
  background-size: 400px 110px;
  -webkit-mask-image: linear-gradient(#000 55%, transparent);
  mask-image: linear-gradient(#000 55%, transparent);
  transform-origin: top center;
  animation:
    kci-sway 7s ease-in-out infinite alternate,
    kci-rail 70s linear infinite;
}

@keyframes kci-drift  { from { background-position: 0 0; }   to { background-position: 240px 240px; } }
@keyframes kci-stitch { from { background-position: 0 0; }   to { background-position: -300px 0; } }
@keyframes kci-rail   { from { background-position: 0 0; }   to { background-position: 400px 0; } }
@keyframes kci-sway   { from { transform: rotate(-1.4deg); } to { transform: rotate(1.4deg); } }

/* ===========================================================
   2) LAYOUT CENTRADO  (root = contenedor, sidebar = logo)
   =========================================================== */

#root {
  position: relative;
  z-index: 1;
}

/* Contenedor principal: pantalla completa, columna centrada */
.muiltr-1dbnzze-root {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 18px;
  box-sizing: border-box;
  padding: 24px 16px !important;
  overflow-y: auto;
  background: transparent !important;
  box-shadow: none !important;
}

/* Sidebar -> bloque del logo, centrado sobre la tarjeta */
.muiltr-yfjwzw-sidebar {
  display: flex !important;
  flex: none !important;
  align-items: center !important;
  justify-content: center !important;
  width: min(300px, 72vw) !important;
  height: 110px !important;
  min-height: 0 !important;
  margin: auto 0 0 !important;   /* empuja hacia el centro vertical */
  padding: 0 !important;
  background: var(--kci-logo) center / contain no-repeat !important;
  box-shadow: none !important;
  border: 0 !important;
  filter: drop-shadow(0 6px 22px rgba(0, 0, 0, 0.55));
  animation: kci-logo-in 0.9s cubic-bezier(0.1, 0.9, 0.2, 1) both,
             kci-float 6s ease-in-out 0.9s infinite;
}

/* oculta el contenido original del sidebar (logo por defecto de Traccar) */
.muiltr-yfjwzw-sidebar > * {
  display: none !important;
}
/* Si tu logo es oscuro y se pierde sobre el fondo, descomenta:
.muiltr-yfjwzw-sidebar { filter: brightness(0) invert(1) drop-shadow(0 6px 22px rgba(0,0,0,.55)); }
*/

/* Wrapper del formulario (el Paper) -> transparente y centrado */
.muiltr-1dbnzze-root > :not(.muiltr-yfjwzw-sidebar) {
  display: flex !important;
  justify-content: center !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 0 auto !important;   /* par del margin-top:auto del logo = centrado vertical */
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  border-radius: 0 !important;
}

@keyframes kci-logo-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes kci-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ===========================================================
   3) TARJETA FLUENT (ACRILICO)
   =========================================================== */

form:has(input[name="password"]) {
  position: relative !important;
  width: min(420px, 92vw) !important;
  box-sizing: border-box;
  padding: 34px 36px 28px !important;
  color: #fff !important;
  overflow: hidden;

  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    rgba(28, 28, 30, 0.45) !important;
  backdrop-filter: blur(32px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(32px) saturate(150%) !important;

  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-top-color: rgba(255, 255, 255, 0.35) !important;
  border-radius: 8px !important;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;

  animation: kci-card-in 0.75s cubic-bezier(0.1, 0.9, 0.2, 1) 0.15s both;
}

/* Barra superior de acento con brillo recorriendo (hilo rojo) */
form:has(input[name="password"])::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--kci-red), #fff, var(--kci-red), transparent);
  background-size: 200% 100%;
  animation: kci-thread 4s linear infinite;
}

@keyframes kci-card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes kci-thread {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ---------- Texto ---------- */
form:has(input[name="password"]) input,
form:has(input[name="password"]) label,
form:has(input[name="password"]) .MuiTypography-root,
form:has(input[name="password"]) .MuiLink-root,
form:has(input[name="password"]) .MuiSvgIcon-root {
  color: #fff !important;
}
form:has(input[name="password"]) label { opacity: 0.8; }

/* ---------- Campos estilo Fluent ---------- */
form:has(input[name="password"]) .MuiOutlinedInput-root {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 4px !important;
  transition: background 0.2s ease;
}
form:has(input[name="password"]) .MuiOutlinedInput-root:hover {
  background: rgba(255, 255, 255, 0.12);
}
form:has(input[name="password"]) .MuiOutlinedInput-root.Mui-focused {
  background: rgba(255, 255, 255, 0.14);
}
form:has(input[name="password"]) .MuiOutlinedInput-notchedOutline {
  border-color: rgba(255, 255, 255, 0.28) !important;
  border-width: 1px !important;
}
form:has(input[name="password"]) .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline {
  border-color: rgba(255, 255, 255, 0.55) !important;
}
form:has(input[name="password"]) .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline {
  border-color: var(--kci-red) !important;
  border-width: 2px !important;
}

/* ---------- Boton primario ---------- */
form:has(input[name="password"]) .MuiButton-contained {
  background: var(--kci-red) !important;
  color: #fff !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  text-transform: none !important;
  font-weight: 600;
  transition: transform 0.12s ease, filter 0.2s ease;
}
form:has(input[name="password"]) .MuiButton-contained:hover { filter: brightness(1.12); }
form:has(input[name="password"]) .MuiButton-contained:active { transform: scale(0.98); }

/* ===========================================================
   4) RESPONSIVE Y ACCESIBILIDAD
   =========================================================== */

@media (max-width: 480px) {
  .muiltr-yfjwzw-sidebar { height: 84px !important; }
  form:has(input[name="password"]) { padding: 28px 22px 22px !important; }
  html::before { height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  body,
  body::before,
  body::after,
  html::before,
  .muiltr-yfjwzw-sidebar,
  form:has(input[name="password"]),
  form:has(input[name="password"])::before {
    animation: none !important;
  }
}