/* GS CRM — Sign in (solar receiver + control panel). Builds on app.css tokens. */

.auth-body {
  --auth-bg: #07111F;
  --auth-bg-2: #0B1726;
  --auth-wire: #2C3E50;
  --auth-photon: #FFD166;
  --auth-powered: #34D399;
  --auth-text: #E6EDF7;
  --auth-text-2: #B6C2D3;
  --auth-muted: #8A99AE;
  --auth-line: rgba(148, 163, 184, 0.16);
  --auth-field: rgba(7, 17, 31, 0.72);
  margin: 0;
  min-height: 100vh;
  background: var(--auth-bg);
  color: var(--auth-text);
}

.auth-stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(900px 520px at 26% 38%, rgba(64, 88, 136, 0.16), transparent 70%),
    linear-gradient(180deg, var(--auth-bg-2) 0%, var(--auth-bg) 64%, #060e1a 100%);
}

/* Horizon line and ground plane span both halves so the scene reads as one space. */
.auth-stage::before,
.auth-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: -1;
}

.auth-stage::before {
  top: 71%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.14) 20%, rgba(148, 163, 184, 0.08) 80%, transparent);
}

.auth-stage::after {
  top: 71%;
  bottom: 0;
  background: linear-gradient(180deg, rgba(20, 34, 56, 0.35), transparent 70%);
}

/* ── Solar receiver ── */

.auth-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px 48px 48px;
  min-width: 0;
}

.auth-panel {
  width: min(640px, 100%);
  height: auto;
  overflow: visible;
  transform: translateY(3%);
}

.auth-impact {
  fill: none;
  stroke: #FFF3B0;
  stroke-width: 2.5;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.auth-caption {
  margin: 8px 0 0;
  color: var(--auth-muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  text-align: center;
}

/* Powered state */
.auth-stage.is-powered .auth-panel-cells polygon {
  fill: #7a5c10;
  stroke: #FFF3B0;
  stroke-width: 1.4;
}

.auth-stage.is-powered .auth-panel-frame { stroke: #FFE680; stroke-width: 1.4; }
.auth-stage.is-powered .auth-junction-led { fill: var(--auth-powered); }

.auth-panel-cells,
.auth-panel-frame {
  transition: filter 0.8s ease 0.15s;
}

.auth-stage.is-powered .auth-panel-cells {
  filter: drop-shadow(0 0 4px rgba(255, 236, 140, 0.95)) drop-shadow(0 0 18px rgba(255, 200, 60, 0.6));
}

.auth-stage.is-powered .auth-panel-frame {
  filter: drop-shadow(0 0 10px rgba(255, 214, 90, 0.7));
}

.auth-stage.is-impact .auth-impact {
  animation: auth-impact 0.6s ease-out forwards;
}

@keyframes auth-impact {
  0% { opacity: 0.9; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(3.2); }
}

/* ── Wire ── */

.auth-wire {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}

.auth-wire-base,
.auth-wire-lit {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.auth-wire-base { stroke: var(--auth-wire); }

.auth-wire-lit {
  stroke: #FFE680;
  stroke-width: 3;
  stroke-dasharray: 0 100000;
  opacity: 0;
  filter: drop-shadow(0 0 3px rgba(255, 244, 180, 0.95)) drop-shadow(0 0 12px rgba(255, 200, 60, 0.75));
  transition: opacity 0.4s ease;
}

.auth-stage.is-energised .auth-wire-lit { opacity: 1; }
.auth-stage.is-powered .auth-wire-lit { opacity: 0.9; }

.auth-wire-port { fill: #0b1220; stroke: #4b5a70; stroke-width: 1.2; transition: fill 0.25s ease, stroke 0.25s ease; }
.auth-stage.is-energised .auth-wire-port { fill: #FFFFFF; stroke: #FFE066; filter: drop-shadow(0 0 6px rgba(255, 220, 90, 0.95)); }

.auth-photon { opacity: 0; transition: opacity 0.15s ease; }
.auth-stage.is-energised .auth-photon { opacity: 1; }
.auth-photon { filter: drop-shadow(0 0 10px rgba(255, 220, 90, 0.95)) drop-shadow(0 0 28px rgba(255, 190, 40, 0.7)); }
.auth-photon-glow { fill: #FFE066; opacity: 0.95; }
.auth-photon-core { fill: #FFFFFF; }

/* ── Control panel ── */

.auth-control {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 48px 48px 32px 32px;
  min-width: 0;
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  padding: 36px 36px 30px;
  border-radius: 16px;
  border: 1px solid var(--auth-line);
  background: rgba(12, 22, 38, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(115%);
  backdrop-filter: blur(14px) saturate(115%);
  box-shadow: 0 24px 60px rgba(2, 6, 14, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  object-fit: cover;
  flex-shrink: 0;
}

.auth-brand-text { display: grid; gap: 2px; line-height: 1; }

.auth-wordmark {
  font-family: "Outfit", "DM Sans", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--auth-text);
}

.auth-wordmark span { color: var(--primary-hover); }

.auth-byline {
  font-size: 12px;
  font-weight: 500;
  color: var(--auth-muted);
  letter-spacing: 0.01em;
}

.auth-title {
  margin: 28px 0 6px;
  font-size: 26px;
  line-height: 1.2;
  color: var(--auth-text);
}

.auth-subtitle {
  margin: 0 0 24px;
  color: var(--auth-text-2);
  font-size: 14px;
}

.auth-alert {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #fecaca;
  font-size: 14px;
}

.auth-alert[hidden] { display: none; }

.auth-form { display: grid; gap: 18px; }

.auth-field { display: grid; gap: 7px; }

.auth-field label {
  color: var(--auth-text-2);
  font-size: 13px;
  font-weight: 500;
}

.auth-input-wrap { position: relative; }

.auth-input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--auth-muted);
  pointer-events: none;
  transition: color 0.15s ease;
}

.auth-input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-sm);
  background: var(--auth-field);
  color: var(--auth-text);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.password-field .auth-input { padding-right: 46px; }

.auth-input:hover { border-color: rgba(148, 163, 184, 0.28); }

.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.28);
  background: rgba(7, 17, 31, 0.9);
}

.auth-input-wrap:focus-within .auth-input-icon { color: var(--primary-hover); }

.auth-input[aria-invalid="true"] { border-color: rgba(239, 68, 68, 0.55); }

.auth-input:-webkit-autofill {
  -webkit-text-fill-color: var(--auth-text);
  -webkit-box-shadow: 0 0 0 1000px #0c1626 inset;
  caret-color: var(--auth-text);
}

.auth-body .password-toggle:hover { background: rgba(148, 163, 184, 0.1); }

.auth-submit {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary-fill, var(--primary));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
  transition: background 0.15s ease, box-shadow 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.auth-submit:hover { background: var(--primary-fill-hover, #4f46e5); box-shadow: 0 10px 24px rgba(99, 102, 241, 0.32); }
.auth-submit:active { transform: translateY(1px); }

.auth-submit:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 3px;
}

.auth-submit-arrow,
.auth-submit-check {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.auth-submit-check,
.auth-spinner { display: none; }

.auth-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: auth-spin 0.7s linear infinite;
}

.auth-submit[data-state="loading"] { cursor: progress; background: #5558e8; }
.auth-submit[data-state="loading"] .auth-spinner { display: inline-block; }
.auth-submit[data-state="loading"] .auth-submit-arrow { display: none; }

.auth-submit[data-state="success"] {
  cursor: default;
  animation: auth-confirm 0.35s ease-out;
  filter: brightness(1.08);
}

.auth-submit[data-state="success"] .auth-submit-check { display: inline-block; }
.auth-submit[data-state="success"] .auth-submit-arrow { display: none; }

@keyframes auth-spin { to { transform: rotate(360deg); } }

@keyframes auth-confirm {
  0% { transform: scale(1); }
  45% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.auth-status {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--auth-muted);
  font-size: 13px;
  text-align: center;
}

.auth-stage.is-powered .auth-status { color: var(--auth-text-2); }

.auth-footer {
  margin: 0;
  color: rgba(138, 153, 174, 0.7);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* ── Responsive ── */

@media (max-width: 1100px) {
  .auth-caption { display: none; }
  .auth-visual { padding: 40px 16px 40px 32px; }
  .auth-control { padding: 40px 32px 28px 16px; }
  .auth-card { padding: 32px 28px 26px; }
}

@media (max-width: 900px) {
  .auth-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .auth-stage::before,
  .auth-stage::after { top: 170px; }

  .auth-visual { padding: 20px 24px 0; height: 190px; }
  .auth-panel { width: auto; height: 100%; transform: none; }
  .auth-caption,
  .auth-wire { display: none; }

  .auth-control {
    justify-content: flex-start;
    padding: 8px 20px 28px;
  }
}

@media (max-width: 560px) {
  .auth-visual { display: none; }

  .auth-stage::before,
  .auth-stage::after { display: none; }

  .auth-control { padding: 40px 16px 24px; }

  .auth-card {
    padding: 28px 22px 24px;
    border-radius: 14px;
  }

  .auth-title { margin-top: 24px; font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-panel-cells polygon,
  .auth-panel-cells,
  .auth-panel-frame,
  .auth-wire-lit,
  .auth-submit {
    transition: none;
  }

  .auth-submit[data-state="success"],
  .auth-stage.is-impact .auth-impact { animation: none; }

  .auth-spinner { animation-duration: 1.6s; }
}

/* Signed-out goodbye screen */
.goodbye-body {
  margin: 0;
  min-height: 100vh;
}

.goodbye-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(720px 420px at 50% 28%, rgba(64, 88, 136, 0.22), transparent 68%),
    linear-gradient(180deg, #0B1726 0%, #07111F 62%, #060e1a 100%);
}

.goodbye-card {
  width: min(420px, 100%);
  text-align: center;
  animation: goodbye-rise 0.55s ease-out both;
}

.goodbye-logo {
  display: block;
  width: min(240px, 72vw);
  height: auto;
  margin: 0 auto 28px;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.35));
}

.goodbye-title {
  margin: 0 0 10px;
  font-family: Outfit, DM Sans, sans-serif;
  font-size: clamp(1.45rem, 3.2vw, 1.85rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #E6EDF7;
}

.goodbye-sub {
  margin: 0 0 26px;
  color: #8A99AE;
  font-size: 0.98rem;
  line-height: 1.5;
}

.goodbye-progress {
  height: 3px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
  margin: 0 auto 18px;
  max-width: 220px;
}

.goodbye-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  animation: goodbye-bar 2.1s ease-in-out forwards;
}

.goodbye-skip {
  margin: 0;
  font-size: 0.88rem;
}

.goodbye-skip a {
  color: #93c5fd;
  text-decoration: none;
}

.goodbye-skip a:hover {
  text-decoration: underline;
}

@keyframes goodbye-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes goodbye-bar {
  from { width: 0; }
  to { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .goodbye-card,
  .goodbye-progress span {
    animation: none;
  }
  .goodbye-progress span {
    width: 100%;
  }
}
