/**
 * Pasarguard — Authentication pages (login, forgot password, reset)
 */

/* tokens.css is loaded via <link> in layouts */

/* ─── Auth layout ─── */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--color-bg);
  background-image: var(--gradient-mesh);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-surface);
  opacity: 0.6;
  pointer-events: none;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 40rem;
  height: 40rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 91, 255, 0.08) 0%, transparent 70%);
  top: -15rem;
  left: -10rem;
  pointer-events: none;
}

[data-theme='dark'] .auth-page::after,
html[data-theme-resolved='dark'] .auth-page::after {
  background: radial-gradient(circle, rgba(129, 140, 248, 0.12) 0%, transparent 70%);
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
}

.auth-container--wide {
  max-width: 32rem;
}

/* ─── Auth card (glass) ─── */
.auth-card {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid var(--glass-border-subtle);
  border-radius: var(--radius-2xl);
  box-shadow: var(--glass-shadow), var(--shadow-lg);
  padding: var(--space-8);
  animation: authFadeIn var(--duration-slow) var(--ease-out) both;
}

@keyframes authFadeIn {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Brand header ─── */
.auth-brand {
  text-align: center;
  margin-bottom: var(--space-8);
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-xl);
  background: var(--gradient-primary);
  color: var(--color-text-inverse);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-md), 0 4px 14px rgba(99, 91, 255, 0.25);
}

.auth-brand__title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.02em;
}

.auth-brand__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: 0;
  line-height: var(--leading-relaxed);
}

/* ─── Auth form ─── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-form__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.auth-form__label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
}

.auth-form__input-wrap {
  position: relative;
}

.auth-form__input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  padding-inline-start: var(--space-4);
  padding-inline-end: var(--space-10);
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
  outline: none;
}

.auth-form__input::placeholder {
  color: var(--input-placeholder);
}

.auth-form__input:hover:not(:disabled):not(:focus) {
  border-color: var(--color-border-strong);
}

.auth-form__input:focus {
  border-color: var(--input-border-focus);
  box-shadow: var(--focus-ring);
}

.auth-form__input.is-invalid {
  border-color: var(--color-danger);
  box-shadow: var(--shadow-glow-danger);
}

.auth-form__input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-end: var(--space-3);
  color: var(--color-text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.auth-form__toggle-password {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-end: var(--space-3);
  background: none;
  border: none;
  padding: var(--space-1);
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease-out);
}

.auth-form__toggle-password:hover {
  color: var(--color-text-secondary);
}

.auth-form__error {
  font-size: var(--text-xs);
  color: var(--color-danger-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.auth-form__hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
}

/* ─── Remember & links row ─── */
.auth-form__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.auth-form__checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  user-select: none;
}

.auth-form__checkbox input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.auth-form__link {
  font-size: var(--text-sm);
  color: var(--color-text-link);
  text-decoration: none;
  font-weight: var(--font-medium);
  transition: color var(--duration-fast) var(--ease-out);
}

.auth-form__link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ─── Submit button ─── */
.auth-form__submit {
  width: 100%;
  padding: var(--space-3) var(--space-6);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-text-inverse);
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    opacity var(--duration-normal) var(--ease-out);
  box-shadow: var(--shadow-sm), 0 2px 8px rgba(99, 91, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.auth-form__submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), 0 4px 12px rgba(99, 91, 255, 0.3);
}

.auth-form__submit:active:not(:disabled) {
  transform: translateY(0);
}

.auth-form__submit:disabled,
.auth-form__submit.is-loading {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.auth-form__submit .spinner {
  display: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-inline: auto;
}

.auth-form__submit.is-loading .spinner {
  display: block;
}

.auth-form__submit.is-loading .auth-form__submit-text {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Auth alerts ─── */
.auth-alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  animation: authFadeIn var(--duration-normal) var(--ease-out);
}

.auth-alert--error {
  background: var(--color-danger-subtle);
  color: var(--color-danger-text);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-alert--success {
  background: var(--color-success-subtle);
  color: var(--color-success-text);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.auth-alert--info {
  background: var(--color-info-subtle);
  color: var(--color-info-text);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* ─── Footer links ─── */
.auth-footer {
  text-align: center;
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
}

.auth-footer__text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: 0;
}

.auth-footer__text a {
  color: var(--color-text-link);
  font-weight: var(--font-medium);
  text-decoration: none;
}

.auth-footer__text a:hover {
  text-decoration: underline;
}

/* ─── Theme toggle on auth ─── */
.auth-theme-toggle {
  position: fixed;
  top: var(--space-4);
  inset-inline-start: var(--space-4);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border-subtle);
  border-radius: var(--radius-lg);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-out),
    color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}

.auth-theme-toggle:hover {
  background: var(--glass-bg-strong);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ─── Split auth layout (optional) ─── */
.auth-split {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

@media (min-width: 64rem) {
  .auth-split {
    grid-template-columns: 1fr 1fr;
  }

  .auth-split__panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-12);
    background: var(--gradient-primary);
    color: var(--color-text-inverse);
    position: relative;
    overflow: hidden;
  }

  .auth-split__panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
  }

  .auth-split__panel-content {
    position: relative;
    z-index: 1;
    max-width: 28rem;
  }

  .auth-split__panel h1 {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    margin: 0 0 var(--space-4);
    line-height: var(--leading-tight);
  }

  .auth-split__panel p {
    font-size: var(--text-lg);
    opacity: 0.9;
    line-height: var(--leading-relaxed);
    margin: 0;
  }

  .auth-split__form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    background: var(--color-bg);
    background-image: var(--gradient-mesh);
  }

  .auth-split__form-side .auth-card {
    box-shadow: var(--shadow-lg);
    max-width: 26rem;
    width: 100%;
  }
}

/* ─── Responsive ─── */
@media (max-width: 30rem) {
  .auth-page {
    padding: var(--space-4);
    align-items: flex-start;
    padding-top: var(--space-12);
  }

  .auth-card {
    padding: var(--space-6);
    border-radius: var(--radius-xl);
  }

  .auth-brand__title {
    font-size: var(--text-lg);
  }
}
