/**
 * Login & Register — original brand look with clean layout
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --logo-width: 50%;
  --main-color: #2f6fed;
  --main-color-hover: #255fd4;
  --main-color-dark: #1d4fc2;
  --auth-page-bg: #ffffff;
  --auth-overlay: transparent;
  --auth-card-bg: #ffffff;
  --auth-input-bg: #f8fafc;
  --auth-input-border: #e2e8f0;
  --auth-input-focus: #2f6fed;
  --auth-text-dark: #0f172a;
  --auth-text-muted: #64748b;
  --auth-link: #2f6fed;
  --auth-link-hover: #255fd4;
  --auth-max-width: 1000px;
  --auth-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --auth-duration: 0.55s;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body.auth-page {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--auth-page-bg);
  color: var(--auth-text-dark);
}

#app {
  margin: 0 auto;
  width: 100%;
  max-width: var(--auth-max-width);
}

/* Full-page background image with light overlay */
.auth-bg {
  position: relative;
  min-height: 100vh;
  padding: 2rem 1.5rem 5rem;
  background-color: var(--auth-page-bg);
  background-image: url('../js/login/login_bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.auth-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--auth-overlay);
  pointer-events: none;
}

/* Soft gradient at bottom so footer text reads on any background */
.auth-bg::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 140px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.2) 60%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

.auth-bg > * {
  position: relative;
  z-index: 1;
}

/* Page entrance animations */
@keyframes authLogoIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes authFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-logo-wrap {
  display: flex;
  justify-content: center;
  padding-top: 4rem;
  margin-bottom: 2rem;
  animation: authLogoIn var(--auth-duration) var(--auth-ease) 0.05s both;
}

.auth-heading {
  animation: authFadeUp var(--auth-duration) var(--auth-ease) 0.12s both;
}

.auth-form-wrap .auth-card {
  animation: authFadeUp 0.6s var(--auth-ease) 0.22s both;
}

.auth-switch {
  animation: authFadeUp 0.5s var(--auth-ease) 0.34s both;
}

.auth-copyright {
  animation: authFadeIn 0.5s ease 0.44s both;
}

.auth-alert.is-visible {
  animation: authFadeUp 0.45s var(--auth-ease) both;
}

@media (prefers-reduced-motion: reduce) {
  .auth-logo-wrap,
  .auth-heading,
  .auth-form-wrap .auth-card,
  .auth-switch,
  .auth-copyright,
  .auth-alert.is-visible {
    animation: none;
  }

  .auth-support-panel.is-visible {
    animation: none;
  }
}

.auth-logo {
  width: var(--logo-width);
  height: auto;
  display: block;
  object-fit: contain;
}

/* Headings */
.auth-heading {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
}

.auth-subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: #ffffff;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

/* Alerts */
.auth-alert {
  display: none;
  max-width: 520px;
  margin: 0 auto 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
}

.auth-alert.is-visible {
  display: block;
}

.auth-alert--error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.auth-alert--success {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

/* Login support panel — shown when user cannot sign in */
.auth-support-panel {
  display: none;
  max-width: 520px;
  margin: 0 auto 1.25rem;
  padding: 1.1rem 1rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--auth-input-border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

.auth-support-panel.is-visible {
  display: block;
  animation: authFadeUp 0.45s var(--auth-ease) both;
}

.auth-support-panel__title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #991b1b;
  text-align: center;
  line-height: 1.4;
}

.auth-support-panel__subtitle {
  margin: 0 0 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--auth-text-muted);
  text-align: center;
}

.auth-support-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.auth-support-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--auth-input-border);
  background: var(--auth-input-bg);
  color: var(--auth-text-dark);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.auth-support-option:hover {
  border-color: var(--main-color);
  background: #ffffff;
  box-shadow: 0 4px 12px var(--brand-shadow);
  transform: translateY(-1px);
}

.auth-support-option__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.1);
  font-size: 1rem;
  flex-shrink: 0;
}

.auth-support-option__label {
  flex: 1;
}

/* Form area */
.auth-form-wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 0.25rem;
}

.auth-card {
  background: var(--auth-card-bg);
  border: 1px solid var(--auth-input-border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  padding: 1.25rem 1rem 1.75rem;
}

.auth-card-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Input rows — original side-by-side style */
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--auth-input-bg);
  border: 1px solid var(--auth-input-border);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  min-height: 50px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-row:focus-within {
  border-color: var(--auth-input-focus);
  box-shadow: 0 0 0 3px var(--brand-shadow);
}

.auth-row-label {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--auth-text-dark);
  white-space: nowrap;
}

.auth-row input[type="text"],
.auth-row input[type="password"],
.auth-row input[type="email"],
.auth-row input[type="tel"] {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  color: var(--auth-text-dark);
  text-align: right;
}

.auth-row input::placeholder {
  color: #b9b9b9;
}

/* Phone field with country code */
.auth-row--phone {
  align-items: center;
}

.auth-phone-field {
  flex: 1;
  min-width: 0;
}

.auth-row--phone .iti {
  width: 100%;
}

.auth-row--phone .iti__tel-input,
.auth-row--phone .iti input[type="tel"] {
  width: 100% !important;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  color: var(--auth-text-dark);
  text-align: left;
  padding: 0;
  margin: 0;
}

.auth-row--phone .iti__selected-dial-code {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--auth-text-dark);
  margin-left: 0.15rem;
}

.auth-row--phone .iti__country-container {
  padding-right: 0.35rem;
}

.auth-row--phone .iti__selected-country {
  background: transparent;
  border-radius: 6px;
  padding: 0 0.35rem 0 0;
}

.auth-row--phone .iti__selected-country-primary {
  padding: 0;
}

.auth-row--phone .iti__arrow {
  border-top-color: var(--auth-text-muted);
}

.auth-row--phone .iti__dropdown-content {
  border-radius: 10px;
  border: 1px solid var(--auth-input-border);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  max-width: min(100vw - 2rem, 360px);
}

.auth-row--phone .iti__search-input {
  border: 1px solid var(--auth-input-border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-family: inherit;
}

.auth-row--radios {
  flex-wrap: wrap;
}

.auth-radios {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--auth-text-dark);
  cursor: pointer;
}

.auth-radio input {
  accent-color: var(--main-color);
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Terms row */
.auth-row--terms {
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-terms {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
}

.auth-terms input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--main-color);
  flex-shrink: 0;
}

.auth-terms label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--auth-text-dark);
  line-height: 1.4;
}

.auth-terms a {
  color: var(--main-color);
  text-decoration: underline;
  font-weight: 700;
}

/* Blue primary button */
.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--main-color) 0%, var(--main-color-dark) 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--brand-shadow-strong);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.auth-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--main-color-hover) 0%, var(--main-color-dark) 100%);
  box-shadow: 0 6px 18px var(--brand-shadow-strong);
}

.auth-btn:active:not(:disabled) {
  transform: translateY(0);
}

.auth-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Switch link — high contrast on background image */
.auth-switch {
  text-align: center;
  margin-top: 2rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.auth-switch a {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 24px;
  text-decoration: none;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.auth-switch a:hover {
  color: #ffffff;
  background: var(--main-color);
  border-color: var(--main-color);
}

/* Copyright */
.auth-copyright {
  position: absolute;
  bottom: 2vh;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.5);
  padding: 0 1rem;
  z-index: 2;
}

/* Hide injected app animations on auth */
.auth-page .anim-live-bg,
.auth-page .anim-particles-canvas,
.auth-page .page-transition-loader {
  display: none !important;
}

@media (min-width: 640px) {
  .auth-bg {
    padding: 2.5rem 2rem 5rem;
  }

  .auth-form-wrap {
    max-width: 560px;
  }
}

@media (max-width: 400px) {
  .auth-logo-wrap {
    padding-top: 2.5rem;
  }

  .auth-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .auth-row input {
    text-align: left;
  }

  .auth-row--phone {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .auth-row--phone .auth-row-label {
    width: 100%;
  }

  .auth-radios {
    justify-content: flex-start;
  }
}
