/* ============================================================
   SAYNET SMART HOMES — Authentication Experience
   ============================================================ */

:root {
  --error: #B85450;
  --success: #3F7657;
  --error-soft: rgba(184, 84, 80, 0.08);
  --success-soft: rgba(63, 119, 87, 0.1);
}

/* ---------- Auth header ---------- */
.auth-header {
  position: relative;
  z-index: 20;
  height: 76px;
  background: rgba(248, 246, 241, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(31, 36, 33, 0.06);
}
.auth-header .header-inner { height: 100%; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #4A524B;
  padding: 9px 16px;
  border-radius: 999px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.back-link svg { width: 18px; height: 18px; }
.back-link:hover { background: var(--beige); color: var(--forest); }

/* ---------- Layout ---------- */
.auth-main {
  display: grid;
  grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
  min-height: calc(100vh - 76px);
  background: var(--ivory);
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 52px 24px;
}
.auth-inner { width: min(462px, 100%); animation: panelIn 0.6s var(--ease); }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.auth-eyebrow {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}
.auth-title {
  font-size: clamp(1.75rem, 2.6vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 12px;
}
.auth-desc { color: #5A625C; margin-bottom: 30px; }

/* ---------- Views & transitions ---------- */
.auth-view { display: none; }
.auth-view.active { display: block; animation: viewIn 0.45s var(--ease); }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Form fields ---------- */
.field { margin-bottom: 18px; }

.field-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  color: #3F4741;
  margin-bottom: 8px;
}

.field-control {
  position: relative;
  display: flex;
  align-items: stretch;
}

.field-input {
  width: 100%;
  height: 52px;
  border: 1.5px solid rgba(31, 36, 33, 0.12);
  border-radius: 14px;
  background: var(--white);
  padding: 0 46px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
}
.field-input::placeholder { color: #ABA9A0; }
.field-input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184, 154, 99, 0.16); }
.field-input:hover:not(:focus) { border-color: rgba(31, 36, 33, 0.24); }

.field-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sage);
  pointer-events: none;
  transition: color 0.25s var(--ease);
}
.field-icon svg { width: 20px; height: 20px; }
.field-control:focus-within .field-icon { color: var(--forest); }

.field-check {
  position: absolute;
  right: 46px;
  top: 50%;
  transform: translateY(-50%) scale(0.4);
  color: var(--success);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}
.field-check svg { width: 19px; height: 19px; }
.field.valid .field-check { opacity: 1; transform: translateY(-50%) scale(1); }

.field-msg {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--error);
  line-height: 1.45;
}
.field-msg svg { width: 15px; height: 15px; flex-shrink: 0; }

.field.has-error .field-input { border-color: var(--error); box-shadow: 0 0 0 4px rgba(184, 84, 80, 0.12); }
.field.has-error .field-icon { color: var(--error); }
.field.has-error .field-msg { display: flex; animation: msgIn 0.3s var(--ease); }

.field.valid .field-input { border-color: rgba(63, 119, 87, 0.55); }
.field.valid .field-msg { display: flex; color: var(--success); }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Password toggle ---------- */
.field-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--sage);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.field-toggle svg { width: 20px; height: 20px; }
.field-toggle:hover { background: var(--beige); color: var(--forest); }
.field-toggle .eye-off { display: none; }
.field-toggle.visible .eye { display: none; }
.field-toggle.visible .eye-off { display: block; }

/* ---------- Phone control ---------- */
.phone-control .phone-code {
  width: 118px;
  flex-shrink: 0;
  border-radius: 14px 0 0 14px;
  border-right-width: 1px;
  padding: 0 12px 0 44px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23879887' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  color: var(--charcoal);
  font-weight: 600;
  font-size: 0.92rem;
}
.phone-control .phone-number { border-radius: 0 14px 14px 0; border-left-width: 1px; }
.phone-control .field-check { right: 12px; }

/* ---------- Strength meter ---------- */
.strength { margin-top: 10px; }
.strength-bars { display: flex; gap: 6px; }
.strength-bars span {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: rgba(31, 36, 33, 0.09);
  transition: background 0.35s var(--ease), transform 0.35s var(--ease);
}
.strength-bars span.on { background: var(--sc, var(--sage)); transform: scaleY(1.4); }
.strength-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.strength-label { font-size: 0.76rem; font-weight: 700; letter-spacing: 0.06em; color: var(--sage); text-transform: uppercase; }
.strength-text { font-size: 0.82rem; font-weight: 800; color: var(--sc, var(--sage)); transition: color 0.3s var(--ease); }

/* ---------- Checkbox ---------- */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 0.92rem;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  color: #4A524B;
  user-select: none;
}
.checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox-box {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 2px solid var(--sand);
  background: var(--white);
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.checkbox-box svg { width: 12px; height: 12px; color: var(--white); opacity: 0; transform: scale(0.4); transition: all 0.2s var(--ease); }
.checkbox input:checked + .checkbox-box { background: var(--forest); border-color: var(--forest); }
.checkbox input:checked + .checkbox-box svg { opacity: 1; transform: scale(1); }
.checkbox input:focus-visible + .checkbox-box { box-shadow: 0 0 0 4px rgba(48, 72, 59, 0.18); }

.terms-check { align-items: flex-start; line-height: 1.5; }
.terms-check .checkbox-box { margin-top: 2px; }
.inline-link { color: var(--forest); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; transition: color 0.2s var(--ease); }
.inline-link:hover { color: var(--gold); }

#field-terms .field-msg { margin-left: 31px; }

/* ---------- Buttons ---------- */
.btn-block { width: 100%; }

.btn .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn.loading { pointer-events: none; opacity: 0.85; }
.btn.loading .spinner { display: inline-block; }
.btn.loading .arrow { display: none; }

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

/* ---------- Form banner ---------- */
.form-banner {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 22px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
}
.form-banner.show { display: flex; animation: msgIn 0.4s var(--ease); }
.form-banner svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.form-banner.error {
  background: var(--error-soft);
  border: 1px solid rgba(184, 84, 80, 0.25);
  color: #8E403C;
}
.form-banner.error svg { color: var(--error); }

/* ---------- Divider & social ---------- */
.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 26px 0;
  color: var(--sage);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  white-space: nowrap;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(31, 36, 33, 0.1); }

.social-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 50px;
  border-radius: 14px;
  border: 1.5px solid rgba(31, 36, 33, 0.12);
  background: var(--white);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--charcoal);
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.social-btn svg { width: 20px; height: 20px; }
.social-btn:hover { border-color: rgba(48, 72, 59, 0.4); background: var(--ivory); transform: translateY(-2px); box-shadow: var(--shadow); }

/* ---------- Switch links ---------- */
.auth-switch { text-align: center; margin-top: 26px; color: #5A625C; font-size: 0.95rem; }

.link-btn {
  background: none;
  border: none;
  font-family: inherit;
  color: var(--forest);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.link-btn:hover { color: var(--gold); background: rgba(184, 154, 99, 0.1); }
.link-btn.strong { font-size: 0.98rem; }

/* ---------- Success screens ---------- */
.auth-success { display: none; text-align: center; padding: 30px 4px; }
.auth-success.show { display: block; animation: viewIn 0.5s var(--ease); }

.success-check { width: 84px; height: 84px; margin: 0 auto 24px; }
.success-check circle { stroke: var(--success); stroke-width: 2; fill: var(--success-soft); stroke-dasharray: 260; stroke-dashoffset: 260; animation: drawCircle 0.7s var(--ease) forwards; }
.success-check path { stroke: var(--success); stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: drawCheck 0.45s 0.5s var(--ease) forwards; }
@keyframes drawCircle { to { stroke-dashoffset: 0; } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

.success-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 10px; }
.success-sub { color: #5A625C; max-width: 340px; margin: 0 auto 28px; font-size: 0.98rem; }

/* ---------- Security note ---------- */
.auth-note {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 34px;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--beige), #F6F2E9);
  border: 1px solid rgba(31, 36, 33, 0.06);
  border-radius: 16px;
}
.an-icon { color: var(--forest); flex-shrink: 0; margin-top: 2px; }
.an-icon svg { width: 24px; height: 24px; }
.auth-note strong { font-size: 0.95rem; display: block; margin-bottom: 4px; }
.auth-note p { font-size: 0.85rem; color: #5A625C; line-height: 1.55; }

/* ---------- Right visual ---------- */
.auth-visual { position: relative; overflow: hidden; min-height: 100%; }
.auth-visual .bg { position: absolute; inset: 0; width: 100%; height: 100%; }

.auth-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(168deg, rgba(36, 51, 42, 0.52) 0%, rgba(27, 41, 34, 0.14) 48%, rgba(31, 36, 33, 0.6) 100%);
}

.auth-statement {
  position: absolute;
  top: 7%;
  left: 7%;
  right: 7%;
  z-index: 3;
}
.as-line {
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  font-weight: 800;
  color: var(--ivory);
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-shadow: 0 2px 18px rgba(20, 26, 22, 0.4);
}
.as-line.gold { color: var(--gold-soft); }
.as-sub { color: rgba(248, 246, 241, 0.88); margin-top: 14px; font-size: 1rem; max-width: 340px; line-height: 1.6; }

/* Trust panel */
.auth-trust {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 7%;
  z-index: 4;
  background: rgba(248, 246, 241, 0.93);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(20, 26, 22, 0.35);
}

.at-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.at-title { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.2em; color: var(--sage); }
.at-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--forest);
}

.at-main { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.at-dot {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #3D5A49, var(--forest));
  color: var(--ivory);
  box-shadow: 0 8px 18px rgba(48, 72, 59, 0.35);
}
.at-dot svg { width: 22px; height: 22px; }
.at-status { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em; }

.at-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.at-stat {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(31, 36, 33, 0.08);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.at-stat b { display: block; font-size: 1.15rem; font-weight: 800; color: var(--forest); line-height: 1.2; }
.at-stat span { font-size: 0.67rem; font-weight: 700; color: #6B736C; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .auth-header { height: 64px; }
  .auth-main {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .auth-visual { display: none; }
  .auth-panel { padding: 40px 20px 64px; }
  .auth-inner { animation: none; }
}

@media (max-width: 480px) {
  .social-row { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; align-items: flex-start; gap: 14px; }
  .back-link span { display: none; }
}
