/*
 * File: auth.css
 * Path: /assets/css/auth.css
 * Project: CryptoSphereFi
 */
/* ==========================================================================
   Auth Pages Specific Styles
   ========================================================================== */

.auth-header {
  position: relative;
  width: 100%;
  height: 88px;
  z-index: var(--z-header);
  padding-inline: clamp(16px, 4vw, 24px);
  background: transparent;
  box-sizing: border-box;
}

.auth-header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

.auth-back {
  position: absolute;
  inset-inline-start: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 44px;
  height: 44px;

  border-radius: var(--rad-full);
  color: var(--text-secondary);
  transition: var(--transition-fast);
  text-decoration: none;

  flex: 0 0 auto;
}

.auth-back:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.auth-back:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: var(--sp-8);

  font-weight: 700;
  font-size: 1.25rem;

  color: var(--text-primary);
  text-decoration: none;

  min-width: 0;
  max-width: calc(100% - 112px);
}

.auth-brand__logo {
  display: block;

  width: auto;
  height: 42px;
  max-width: 180px;

  object-fit: contain;
  object-position: center;

  flex: 0 0 auto;
}

/* Hide brand name if logo already contains branding */
.auth-brand__name {
  display: none;
}

.auth-main {
  width: 100%;

  min-height: calc(100vh - 88px);
  min-height: calc(100dvh - 88px);

  display: flex;
  flex-direction: column;

  box-sizing: border-box;
}

.auth-container {
  display: flex;
  flex: 1;

  width: 100%;
  max-width: 100%;

  box-sizing: border-box;
}

/* Mobile auth header spacing */
@media (max-width: 768px) {
  .auth-header {
    height: 104px;
    padding-inline: 20px;
  }

  .auth-header-inner {
    align-items: center;
  }

  .auth-back {
    width: 44px;
    height: 44px;
  }

  .auth-brand {
    max-width: calc(100% - 120px);
  }

  .auth-brand__logo {
    height: 46px;
    max-width: 150px;
  }

  .auth-main {
    min-height: calc(100vh - 104px);
    min-height: calc(100dvh - 104px);
  }
}

@media (max-width: 430px) {
  .auth-header {
    height: 112px;
    padding-inline: 16px;
  }

  .auth-brand__logo {
    height: 44px;
    max-width: 140px;
  }

  .auth-main {
    min-height: calc(100vh - 112px);
    min-height: calc(100dvh - 112px);
  }
}

@media (max-width: 360px) {
  .auth-header {
    height: 108px;
    padding-inline: 14px;
  }

  .auth-brand__logo {
    height: 40px;
    max-width: 128px;
  }

  .auth-main {
    min-height: calc(100vh - 108px);
    min-height: calc(100dvh - 108px);
  }
}

/* ==========================================================================
   Left Visual Panel
   ========================================================================== */
.auth-visual {
  width: 48%;
  background: var(--surface-elevated);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sp-96) var(--sp-64);
  position: relative;
  overflow: hidden;
}

.auth-visual-content {
  position: relative;
  z-index: 2;
  max-width: 480px;
  margin: 0 auto;
}

.auth-visual-content h2 {
  font-size: clamp(1.75rem, 3vw, 2rem);
  margin-bottom: var(--sp-16);
  overflow-wrap: break-word;
}

.auth-visual-content p {
  color: var(--text-secondary);
  font-size: 1.125rem;
  margin-bottom: var(--sp-32);
}

.auth-benefits {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
}

.auth-benefits li {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  font-weight: 500;
  color: var(--text-primary);
}

.auth-benefits svg {
  color: var(--primary);
  flex-shrink: 0;
}

.auth-illustration {
  position: relative;
  margin: var(--sp-64) auto 0;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1/1;
  z-index: 1;
}

.glow-orb {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 150px; height: 150px;
  background: radial-gradient(circle, rgba(124, 92, 252, 0.4) 0%, rgba(79, 124, 255, 0) 70%);
  border-radius: 50%;
  filter: blur(20px);
  z-index: 1;
}

.auth-svg-graphic {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   Right Form Panel
   ========================================================================== */
.auth-form-container {
  width: 52%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--sp-96) clamp(16px, 4vw, 24px);
  background: var(--bg-main);
  box-sizing: border-box;
}

.auth-card {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-24);
  padding: clamp(24px, 5vw, 40px);
  box-shadow: var(--shadow-sm);
  margin-inline: auto;
  box-sizing: border-box;
}

.auth-card-header {
  margin-bottom: var(--sp-32);
}

.auth-card-header h1 {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  margin-bottom: var(--sp-8);
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  line-height: 1.2;
}

.auth-card-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.form-group {
  margin-bottom: var(--sp-20);
  position: relative;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--sp-8);
  color: var(--text-primary);
}

.label-optional {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 0.75rem;
  margin-inline-start: var(--sp-4);
}

.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 var(--sp-16);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--rad-12);
  color: var(--text-primary);
  transition: var(--transition-fast);
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--surface);
}

.form-control[aria-invalid="true"] {
  border-color: var(--danger);
}

.form-control[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(234, 57, 67, 0.2);
}

.form-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active{
  -webkit-box-shadow: 0 0 0 50px var(--surface-elevated) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  background-clip: content-box !important;
}

.field-help {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: var(--sp-8);
}

.field-error {
  display: block;
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: var(--sp-8);
  font-weight: 500;
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.password-wrapper .form-control {
  padding-inline-end: 48px; /* space for toggle */
}

.btn-toggle-password {
  position: absolute;
  right: var(--sp-8);
  width: 44px; height: 44px;
  border-radius: var(--rad-8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  z-index: 2;
}

html[dir="rtl"] .btn-toggle-password {
  right: auto;
  left: var(--sp-8);
}

.btn-toggle-password:hover,
.btn-toggle-password:focus-visible {
  color: var(--text-primary);
  background: var(--surface);
}

/* ==========================================================================
   Password Strength & Requirements
   ========================================================================== */
.password-strength-container {
  margin-top: var(--sp-12);
  margin-bottom: var(--sp-12);
}

.strength-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: var(--sp-8);
}

.strength-text {
  font-weight: 600;
}

.strength-meter {
  display: flex;
  gap: 4px;
  height: 4px;
}

.strength-bar {
  flex: 1;
  background: var(--border);
  border-radius: 2px;
  transition: background var(--transition-normal);
}

/* Strength Colors */
.strength-weak .strength-text { color: var(--danger); }
.strength-weak .strength-bar:nth-child(1) { background: var(--danger); }

.strength-fair .strength-text { color: var(--warning); }
.strength-fair .strength-bar:nth-child(1),
.strength-fair .strength-bar:nth-child(2) { background: var(--warning); }

.strength-good .strength-text { color: var(--primary); }
.strength-good .strength-bar:nth-child(1),
.strength-good .strength-bar:nth-child(2),
.strength-good .strength-bar:nth-child(3) { background: var(--primary); }

.strength-strong .strength-text { color: var(--success); }
.strength-strong .strength-bar { background: var(--success); }

.password-reqs {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-8);
}

.password-reqs li {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  transition: color var(--transition-fast);
}

.password-reqs li.valid {
  color: var(--success);
}
.password-reqs li.valid svg circle {
  fill: var(--success);
  stroke: var(--success);
}

.password-reqs svg {
  flex-shrink: 0;
}

/* ==========================================================================
   Checkbox & Terms
   ========================================================================== */
.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-12);
}

.checkbox-group input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}

.checkbox-group input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-color: var(--primary);
}

.checkbox-group input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-group input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px; left: 6px;
  width: 4px; height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-group label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  cursor: pointer;
}

.checkbox-group a {
  color: var(--primary);
  text-decoration: none;
}
.checkbox-group a:hover {
  text-decoration: underline;
}
.checkbox-group a.disabled-link {
  color: var(--text-secondary);
  text-decoration: none;
}

/* ==========================================================================
   Form Alerts
   ========================================================================== */
.form-alert {
  padding: var(--sp-16);
  border-radius: var(--rad-12);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--sp-24);
  line-height: 1.4;
}

.form-alert.alert-error {
  background: rgba(234, 57, 67, 0.1);
  color: var(--danger);
  border: 1px solid rgba(234, 57, 67, 0.2);
}

.form-alert.alert-success {
  background: rgba(22, 199, 132, 0.1);
  color: var(--success);
  border: 1px solid rgba(22, 199, 132, 0.2);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-full {
  width: 100%;
}

.btn-primary {
  position: relative;
  min-height: 50px;
}

.spinner {
  animation: rotate 2s linear infinite;
}

@keyframes rotate {
  100% { transform: rotate(360deg); }
}

.btn-text-action {
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0;
  cursor: pointer;
}

.btn-text-action:hover {
  text-decoration: underline;
}

.btn-text-action:disabled {
  color: var(--text-secondary);
  cursor: not-allowed;
  text-decoration: none;
}

.auth-redirect {
  text-align: center;
  margin-top: var(--sp-24);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-redirect a {
  color: var(--primary);
  font-weight: 600;
}

/* ==========================================================================
   Verification Specifics
   ========================================================================== */
.verification-email-display {
  margin-top: var(--sp-16);
  padding: var(--sp-12) var(--sp-16);
  background: var(--surface-elevated);
  border-radius: var(--rad-8);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.verification-email-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.verification-email-value {
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
  unicode-bidi: isolate;
}

.verification-wrong-email {
  margin-top: var(--sp-8);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.verification-code-field {
  position: relative;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  unicode-bidi: isolate;
}

.verification-code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: text;
  z-index: 2;
  font-size: 1px;
}

.verification-code-cells {
  display: flex;
  gap: var(--sp-12);
  width: 100%;
  justify-content: space-between;
  z-index: 1;
}

.verification-code-cell {
  width: 48px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--rad-8);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.verification-code-field.is-focused .verification-code-cell.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--surface);
}

.verification-code-field.is-invalid .verification-code-cell {
  border-color: var(--danger);
}

.verification-code-field.is-invalid.is-focused .verification-code-cell.is-active {
  box-shadow: 0 0 0 3px rgba(234, 57, 67, 0.2);
}

.verification-actions {
  margin-top: var(--sp-32);
  display: flex;
  flex-direction: column;
  gap: var(--sp-24);
  align-items: center;
}

.resend-wrapper {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-8);
}

.resend-button {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
}

.missing-email-state {
  text-align: center;
}

.missing-email-icon {
  margin: 0 auto var(--sp-16);
  display: block;
}

/* ==========================================================================
   Login Specifics
   ========================================================================== */
.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-24);
  font-size: 0.875rem;
}

.login-options .checkbox-group {
  margin-bottom: 0;
}

.forgot-password-link {
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.forgot-password-link:hover {
  text-decoration: underline;
}

.login-verification-action {
  margin-top: var(--sp-16);
  text-align: center;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.auth-footer {
  padding: var(--sp-24);
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.auth-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-8);
}

.auth-footer a {
  color: var(--text-secondary);
}
.auth-footer a:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   Auth Responsive Rules
   ========================================================================== */
@media (max-width: 1024px) {
  .auth-visual { width: 40%; padding: var(--sp-64) var(--sp-32); }
  .auth-form-container { width: 60%; padding: var(--sp-64) var(--sp-24); }
  .password-reqs { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .auth-container { flex-direction: column; }
  .auth-visual { display: none !important; }
  .auth-form-container { width: 100% !important; padding: var(--sp-32) clamp(12px, 4vw, 20px); }
  .auth-card { 
    width: 100%; 
    max-width: 520px; 
    margin-inline: auto; 
    padding: clamp(20px, 5vw, 32px) clamp(16px, 4vw, 24px); 
    border-radius: var(--rad-16);
  }
  .auth-card-header h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.2;
    word-break: normal;
    overflow-wrap: normal;
  }
  .auth-header { height: 64px; padding-inline: 16px; }
  .auth-header-inner { justify-content: center; position: relative; }
  .auth-back { position: absolute; left: 16px; }
  html[dir="rtl"] .auth-back { left: auto; right: 16px; }
}

@media (max-width: 430px) {
  .login-options { flex-wrap: wrap; gap: 12px; justify-content: space-between; }
  .password-reqs { gap: 6px; }
  .verification-code-cells { gap: var(--sp-8); }
  .verification-code-cell { width: 40px; height: 50px; font-size: 1.25rem; }
}

@media (max-width: 360px) {
  .auth-card { padding: var(--sp-20) var(--sp-16); }
  .auth-brand__logo { max-width: 130px; height: 28px; }
  .login-options { flex-direction: column; align-items: flex-start; }
  .verification-code-cells { gap: 4px; }
  .verification-code-cell { width: 36px; height: 48px; }
}