/* css/csm-page-login.css - Strict adherence to CSM original layout variables */

.login-body {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  /* Always transparent to let the high performance canvas background show */
  background: transparent; 
  font-family: var(--csm-font);     
  overflow: hidden;
  position: relative;
}

#bg-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

/* 
  Solid base adhering identically to your original CSS system.
  Background set exactly to Surface as in your code.
*/
.login-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 900px;
  background: var(--csm-surface);
  border-radius: var(--csm-radius-lg);
  box-shadow: var(--csm-shadow);
  display: flex;
  overflow: hidden;
  border: 1px solid var(--csm-border);
  transform: translateY(20px);
  opacity: 0;
  animation: slideUp 0.5s ease-out forwards;
}

@keyframes slideUp {
  to { transform: translateY(0); opacity: 1; }
}

.login-brand-panel {
  flex: 1;
  background: var(--csm-surface-2);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border-right: 1px solid var(--csm-border);
}

.login-logo-container {
  margin-bottom: 2rem;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
  perspective: 500px;
}

/* Stack every child on the same grid cell — bulletproof centering */
.login-logo-container > * {
  grid-area: 1 / 1;
}

/* ── Orbital Ring System ── */
.ring-svg {
  overflow: visible;
}

.ring-svg circle {
  fill: none;
  stroke: var(--csm-primary-400, #4a9e6a);
  stroke-linecap: round;
}

/* Outer ring — large, slow, 2 long dashes flowing clockwise */
.ring-outer {
  width: 196px;
  height: 196px;
  animation: ringSpin 18s linear infinite;
}

.ring-outer circle {
  stroke-width: 1.4;
  stroke-dasharray: 22 28;
  opacity: 0.3;
  animation: flowCW 4s linear infinite;
}

/* Mid ring — medium, counter-clockwise, 1 accent dash */
.ring-mid {
  width: 164px;
  height: 164px;
  animation: ringSpinReverse 12s linear infinite;
}

.ring-mid circle {
  stroke-width: 1;
  stroke-dasharray: 12 88;
  opacity: 0.2;
  animation: flowCCW 3s linear infinite;
}

/* Inner ring — tight, fast forward, short pulsing dashes */
.ring-inner {
  width: 136px;
  height: 136px;
  animation: ringSpin 8s linear infinite;
}

.ring-inner circle {
  stroke-width: 0.8;
  stroke-dasharray: 4 12.67;
  opacity: 0.15;
  animation: flowCW 2.5s linear infinite;
}

/* Dark mode — glow + brighter */
[data-theme="dark"] .ring-outer circle { opacity: 0.5; }
[data-theme="dark"] .ring-mid circle   { opacity: 0.35; }
[data-theme="dark"] .ring-inner circle { opacity: 0.25; }

[data-theme="dark"] .ring-outer {
  filter: drop-shadow(0 0 4px rgba(52, 211, 153, 0.2));
}
[data-theme="dark"] .ring-mid {
  filter: drop-shadow(0 0 3px rgba(52, 211, 153, 0.15));
}

/* ── Soft Logo Glow ── */
.logo-glow {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--csm-primary-400, #4a9e6a) 0%, transparent 70%);
  animation: glowPulse 4s ease-in-out infinite;
  pointer-events: none;
}

/* ── Keyframes ── */
@keyframes ringSpin {
  to { transform: rotate(360deg); }
}
@keyframes ringSpinReverse {
  to { transform: rotate(-360deg); }
}
@keyframes flowCW {
  to { stroke-dashoffset: -100; }
}
@keyframes flowCCW {
  to { stroke-dashoffset: 100; }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.04; transform: scale(1); }
  50% { opacity: 0.12; transform: scale(1.06); }
}

/* ── Logo (centered via grid stacking) ── */
.logo-animation-wrapper {
  z-index: 1;
}

.user-exact-svg {
  width: 110px;
  height: 110px;
  display: block;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* 
  Perfectly timed looping vector animation exactly as requested.
  It traces the stroke -> fills gradient in -> fades fill out -> reverses stroke -> repeats loop.
*/
.logo-path {
  fill: url(#logoGrad);
  stroke: url(#logoGrad);
  stroke-width: 40;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  animation: energyInfiniteLoop 6s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

/* Delay the second path slightly so they animate organically together */
.logo-path.p2 {
  animation-delay: 0.2s;
}

@keyframes energyInfiniteLoop {
  0%   { stroke-dashoffset: 100;  fill-opacity: 0; stroke-opacity: 1;   }
  20%  { stroke-dashoffset: 0;    fill-opacity: 0; stroke-opacity: 1;   }
  35%  { stroke-dashoffset: 0;    fill-opacity: 1; stroke-opacity: 0.5; }
  65%  { stroke-dashoffset: 0;    fill-opacity: 1; stroke-opacity: 0.5; }
  80%  { stroke-dashoffset: 0;    fill-opacity: 0; stroke-opacity: 1;   }
  100% { stroke-dashoffset: -100; fill-opacity: 0; stroke-opacity: 1;   }
}


.login-brand-panel h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--csm-text);
  margin-bottom: 0.5rem;
}
.login-brand-panel p {
  color: var(--csm-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.login-form-panel {
  flex: 1.2;
  padding: 4rem 3rem;
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-header {
  margin-bottom: 2rem;
}
.login-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--csm-text);
  margin-bottom: 0.5rem;
}
.login-header p {
  color: var(--csm-muted);
  font-size: 0.95rem;
}

/* Perfect rendering of rigorous original input fields */
.input-group {
  margin-bottom: 1.25rem;
}
.input-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--csm-text);
  margin-bottom: 0.4rem;
}
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrapper > .material-icons {
  position: absolute;
  left: 1rem;
  color: var(--csm-muted);
  font-size: 1.2rem;
  transition: color var(--csm-transition);
  pointer-events: none;
}
.input-wrapper input {
  width: 100%;
  padding: 0.75rem 2.8rem 0.75rem 2.8rem;
  border: 1px solid var(--csm-border);
  border-radius: var(--csm-radius-sm);
  background: var(--csm-surface-2);
  color: var(--csm-text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all var(--csm-transition);
  box-sizing: border-box;
}
.input-wrapper input:focus {
  outline: none;
  border-color: var(--csm-primary-500);
  background: var(--csm-surface);
  box-shadow: var(--csm-ring);
}
.input-wrapper:focus-within > .material-icons:first-child {
  color: var(--csm-primary-500);
}

.toggle-pwd {
  position: absolute;
  right: 0.5rem;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: var(--csm-muted);
  padding: 0;
  z-index: 2;
  border-radius: 6px;
  transition: color var(--csm-transition), background var(--csm-transition), transform 0.15s ease;
}
.toggle-pwd:hover {
  color: var(--csm-primary-500);
  background: var(--csm-surface);
}
.toggle-pwd:focus-visible {
  outline: 2px solid var(--csm-primary-500);
  outline-offset: 2px;
}
.toggle-pwd:active {
  transform: scale(0.88);
}
.toggle-pwd .material-icons {
  font-size: 1.2rem;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.toggle-pwd.is-visible .material-icons {
  color: var(--csm-primary-500);
}

.auth-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.5rem 0 2rem;
  font-size: 0.9rem;
}
.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--csm-text);
}
.checkbox-wrap input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--csm-primary-500);
}
.forgot-pwd {
  color: var(--csm-primary-500);
  text-decoration: none;
  font-weight: 600;
}
.forgot-pwd:hover {
  color: var(--csm-primary-600);
}

.btn-login {
  width: 100%;
  padding: 0.85rem;
  background: var(--csm-primary-500);
  color: #fff;
  border: none;
  border-radius: var(--csm-radius-sm);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--csm-transition);
  box-shadow: 0 4px 14px rgba(58, 91, 64, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
}
.btn-login:hover {
  background: var(--csm-primary-600);
  box-shadow: 0 6px 20px rgba(58, 91, 64, 0.4);
  transform: translateY(-1px);
}
.btn-login:active {
  transform: translateY(1px);
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Contenitore posizionato in alto a destra — eredita gli stili .theme-toggle di csm.css */
.login-theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 20;
  background: var(--csm-surface);
  border: 1px solid var(--csm-border);
  border-radius: var(--csm-radius-md);
  box-shadow: var(--csm-shadow);
  min-width: 220px;
  cursor: pointer;
  transition: box-shadow var(--csm-transition);
}
.login-theme-toggle:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}
.login-theme-toggle .theme-toggle {
  margin: 0;
  border-radius: var(--csm-radius-md);
}

/* Messaggio di errore login */
.login-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--csm-red-bg);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--csm-radius-sm);
  color: var(--csm-red);
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}
.login-error .material-icons {
  font-size: 1.15rem;
  flex-shrink: 0;
  color: var(--csm-danger);
}

@media (max-width: 768px) {
  .login-card {
    flex-direction: column;
    max-width: 400px;
    margin: 1.5rem;
  }
  .login-brand-panel, .login-form-panel {
    padding: 2.5rem 2rem;
  }
  .login-brand-panel {
    border-right: none;
    border-bottom: 1px solid var(--csm-border);
  }
}
