:root {
  --navy: #2e3062;
  --navy-dark: #24264f;
  --red: #b3141b;
  --text: #1f2937;
  --muted: #6b7280;
  --input-bg: #f9fafb;
  --input-border: #e5e7eb;
  --disabled-bg: #e9ebf0;
  --disabled-text: #9ca3af;
  --radius: 14px;
  --red-bright: #e30613;
  --red-soft: #fff4f5;
  --teal: #62cdd8;
  --teal-text: #14a2b4;
  --teal-soft: #e7f8fa;
  --orange: #f59e0b;
  --green: #22c55e;
  --border: #e5e7eb;
  --page-bg: #fbfbfd;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: #0b2a52;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ========== Auth page ========== */
.auth-page {
  background: url("../images/bg.jpg") center center / cover no-repeat fixed;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 50px 16px 60px;
}

.back-home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 22px;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(20, 45, 90, 0.35);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.2s, transform 0.2s;
}

.back-home:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.auth-title {
  margin-top: 18px;
  color: #fff;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.3;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.auth-subtitle {
  margin-top: 4px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Card */
.auth-card {
  width: 100%;
  max-width: 448px;
  margin-top: 22px;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.auth-card__header {
  background: var(--navy);
  padding: 24px 20px 26px;
  text-align: center;
  color: #fff;
}

.auth-card__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--navy);
  border-radius: 12px;
}

.auth-card__header h2 {
  font-size: 20px;
  font-weight: 800;
}

.auth-card__body {
  padding: 22px 24px 20px;
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}

.form-group label svg {
  color: var(--red);
  flex-shrink: 0;
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-control::placeholder {
  color: #9ca3af;
}

.form-control:focus {
  background-color: #fff;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(46, 48, 98, 0.12);
}

.form-control.is-invalid {
  border-color: var(--red);
}

.field-error {
  display: block;
  min-height: 0;
  margin-top: 4px;
  font-size: 12px;
  color: var(--red);
}

.field-error:empty {
  display: none;
}

.password-field {
  position: relative;
}

.password-field .form-control {
  padding-left: 42px;
}

.toggle-password {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
}

.toggle-password:hover {
  color: var(--navy);
}

.toggle-password .eye-closed {
  display: none;
}

.toggle-password.is-visible .eye-open {
  display: none;
}

.toggle-password.is-visible .eye-closed {
  display: block;
}

.forgot-link {
  display: inline-block;
  margin: 4px 0 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
}

.forgot-link:hover {
  text-decoration: underline;
}

.form-alert {
  display: none;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fecaca;
}

.form-alert.show {
  display: block;
}

.form-alert--success {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

[hidden] {
  display: none !important;
}

.btn-login {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(46, 48, 98, 0.25);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn-login:hover:not(:disabled) {
  background: var(--navy-dark);
  transform: translateY(-1px);
}

.btn-login:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: not-allowed;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.auth-divider {
  height: 1px;
  margin: 22px 0 18px;
  background: var(--input-border);
}

.register-text {
  text-align: center;
  font-size: 14px;
  color: #374151;
}

.register-link {
  margin-right: 4px;
  font-weight: 800;
  color: var(--red);
}

.register-link:hover {
  text-decoration: underline;
}

/* ========== Signup ========== */
.back-home--light {
  background: #fff;
  border-color: #fff;
  color: var(--navy);
  font-size: 13px;
  padding: 6px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.back-home--light:hover {
  background: #f1f3f8;
}

.back-home span {
  display: flex;
}

.auth-title--md {
  font-size: 32px;
}

.auth-subtitle--sm {
  font-size: 14px;
}

.auth-card--wide {
  max-width: 537px;
}

.stepper {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 16px;
  background: #3f416d;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.step__num {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  transition: background 0.2s, color 0.2s;
}

.step.is-active .step__num,
.step.is-done .step__num {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.step__line {
  width: 34px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.35);
  transition: background 0.2s;
}

.step__line.is-done {
  background: #fff;
}

.signup-body {
  padding: 20px 20px 18px;
}

.signup-body .form-group {
  margin-bottom: 14px;
}

.signup-body .form-group label {
  font-size: 11.5px;
  margin-bottom: 6px;
}

.signup-body .form-group label span {
  display: flex;
}

.signup-body .form-control {
  height: 36px;
  font-size: 12.5px;
  background-color: #fff;
  border-color: #dde2ea;
  border-radius: 10px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-left: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group .form-control {
  flex: 1;
  min-width: 0;
}

.input-prefix {
  flex-shrink: 0;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dde2ea;
  border-radius: 10px;
  background: #f3f4f6;
  font-size: 12px;
  font-weight: 800;
  color: #374151;
  direction: ltr;
}

.ltr-input {
  direction: ltr;
  text-align: right;
}

.ltr-input::placeholder {
  direction: rtl;
}

.strength {
  margin: -4px 0 14px;
  padding: 10px 12px;
  border: 1px solid #eceef2;
  border-radius: 10px;
  background: #f9fafb;
}

.strength__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: #374151;
}

.strength__badge {
  padding: 0 10px;
  border-radius: 999px;
  font-size: 10.5px;
  color: #fff;
}

.strength__bar {
  height: 4px;
  margin: 8px 0;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.strength__bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.25s, background 0.25s;
}

.strength[data-level="weak"] .strength__badge,
.strength[data-level="weak"] .strength__bar span {
  background: var(--red-bright);
}

.strength[data-level="medium"] .strength__badge,
.strength[data-level="medium"] .strength__bar span {
  background: var(--orange);
}

.strength[data-level="strong"] .strength__badge,
.strength[data-level="strong"] .strength__bar span {
  background: #16a34a;
}

.strength__rules {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.strength__rules li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #6b7280;
}

.rule-dot {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c5cad3;
  border-radius: 50%;
  color: #fff;
}

.strength__rules li.ok {
  color: #16a34a;
}

.strength__rules li.ok .rule-dot {
  background: #16a34a;
  border-color: #16a34a;
}

.btn-auth {
  width: 100%;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(46, 48, 98, 0.18);
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn-auth span {
  display: flex;
}

.btn-auth:hover:not(:disabled) {
  background: var(--navy-dark);
}

.btn-auth:disabled {
  background: #d6dce6;
  color: #5b6474;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
  cursor: not-allowed;
}

.btn-auth--outline {
  background: #fff;
  color: #374151;
  border-color: #d6dae1;
  box-shadow: none;
}

.btn-auth--outline:hover:not(:disabled) {
  background: #f8f9fb;
  color: var(--navy);
  border-color: var(--navy);
}

.btn-auth--next {
  margin-top: 2px;
}

.btn-auth--inline {
  width: auto;
  padding: 0 28px;
  margin-top: 14px;
}

.signup-body .auth-divider {
  margin: 14px 0 12px;
}

.signup-body .register-text {
  font-size: 13px;
}

.step-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.step-actions--otp {
  margin-top: 36px;
}

.otp-panel {
  text-align: center;
  padding-top: 4px;
}

.otp-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #fdeeee;
  color: var(--red-bright);
}

.otp-panel h3 {
  font-size: 16px;
  font-weight: 800;
  color: #1f2937;
}

.otp-panel p {
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
}

.otp-panel p b {
  color: var(--red-bright);
  direction: ltr;
  unicode-bidi: isolate;
}

.otp-label {
  display: block;
  margin: 16px 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: #374151;
}

.otp-inputs {
  display: flex;
  justify-content: center;
  gap: 8px;
  direction: ltr;
}

.otp-inputs input {
  width: 34px;
  height: 40px;
  text-align: center;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  color: #1f2937;
  border: 1px solid #d6dae1;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.otp-inputs input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(46, 48, 98, 0.12);
}

.otp-inputs.has-error input {
  border-color: var(--red-bright);
}

.otp-error {
  margin-top: 8px;
}

.otp-panel .otp-resend {
  margin-top: 14px;
}

.otp-resend button {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--red-bright);
  cursor: pointer;
}

.otp-resend button:disabled {
  color: #9ca3af;
  cursor: default;
}

.demo-note {
  max-width: 340px;
  margin: 14px auto 0;
  padding: 8px 12px;
  border: 1px dashed var(--orange);
  border-radius: 8px;
  background: #fffbeb;
  font-size: 11.5px;
  color: #92400e;
}

.demo-note b {
  font-size: 14px;
  letter-spacing: 2px;
  direction: ltr;
  unicode-bidi: isolate;
}

.signup-success {
  padding: 20px 10px 8px;
  text-align: center;
}

.signup-success__icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #dcfce7;
  color: #16a34a;
  box-shadow: 0 0 0 8px #f0fdf4;
}

.signup-success h3 {
  font-size: 19px;
  font-weight: 800;
}

.signup-success p {
  margin-top: 6px;
  font-size: 13px;
}

.signup-success b {
  color: var(--navy);
}

.muted-sm {
  font-size: 12px !important;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .stepper {
    gap: 8px;
  }

  .step__label {
    display: none;
  }

  .step__line {
    width: 40px;
  }

  .step-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .auth-page {
    background-attachment: scroll;
  }

  .auth-wrapper {
    padding-top: 30px;
  }

  .auth-title {
    font-size: 32px;
  }

  .auth-subtitle {
    font-size: 15px;
  }

  .auth-card__body {
    padding: 20px 18px;
  }
}

/* ========== Backend states (loading buttons, forgot password) ========== */
.btn-auth.loading,
.btn-login.loading {
  pointer-events: none;
}

.btn-auth.loading::after,
.btn-login.loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.signup-body > .form-alert,
#forgotForm > .form-alert {
  margin-bottom: 16px;
}

.form-group--spaced {
  margin-top: 24px;
}

/* Step button while required fields are still missing: clickable, but looks secondary */
.btn-auth.is-incomplete:not(:disabled) {
  opacity: 0.75;
  box-shadow: none;
}
