/*
|--------------------------------------------------------------------------
| ibisCar login
|--------------------------------------------------------------------------
| Loaded after external.css, which provides the tokens, reset, header
| (header.site) and footer (footer.site-footer). Only the login panel lives here.
|--------------------------------------------------------------------------
*/

:root {
  --err: #C0392B;
  --err-tint: #FBEAE8;
}

body.auth-page {
  min-height: 100vh;
  min-height: 100dvh;            /* ignores the collapsing mobile address bar */
  overflow-x: hidden;            /* no sideways wobble */
  background: var(--surface-2);
  touch-action: manipulation;    /* no double-tap zoom */
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}


/* ---------- Layout ---------- */

.login-main {
  align-items: flex-start;       /* the panel centres itself with auto margins */
  justify-content: center;
  overflow: visible;
  padding: 24px 20px 56px;
}

.auth-panel {
  width: 100%;
  max-width: 420px;
  margin-block: auto;            /* centred when short, top-aligned when the keyboard shrinks the screen */
  padding: 38px 34px;

  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow:
    0 1px 2px rgba(14, 58, 99, 0.05),
    0 14px 32px -18px rgba(14, 58, 99, 0.28);
}

.auth-view h1 {
  margin-bottom: 8px;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.auth-subtitle {
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.auth-subtitle strong {
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.panel-icon,
.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 52px;
  height: 52px;
  margin-bottom: 18px;

  border-radius: 50%;
  background: var(--orange-tint);
  color: var(--orange);
}

.panel-icon span {
  display: flex;
}

.panel-icon svg,
.success-icon svg {
  width: 24px;
  height: 24px;
}

.success-icon {
  margin-inline: auto;
  background: var(--success-bg);
  color: var(--success);
}


/* ---------- Messages (JS toggles .show) ---------- */

.auth-error {
  display: none;
  margin-bottom: 18px;
  padding: 11px 14px;

  border: 1px solid rgba(192, 57, 43, 0.3);
  border-radius: var(--radius-m);
  background: var(--err-tint);

  font-size: 13px;
  line-height: 1.5;
  color: var(--err);
}

.field-error {
  display: none;
  font-size: 12px;
  color: var(--err);
}

.auth-error.show,
.field-error.show {
  display: block;
}


/* ---------- Fields ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 12px 13px;

  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);

  font-size: 16px;               /* below 16px, iOS zooms the page on focus */
  color: var(--ink);

  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder {
  color: var(--muted-light);
}

.field input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(14, 58, 99, 0.12);
}

.field:has(.field-error.show) input {
  border-color: var(--err);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 64px;
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);

  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;

  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.pw-toggle:hover {
  color: var(--ink);
}


/* ---------- Buttons ---------- */

.auth-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  width: 100%;
  margin-top: 4px;
  padding: 13px 22px;

  border: 0;
  border-radius: var(--radius-s);
  background: var(--orange);
  color: #FFFFFF;

  font-size: 14.5px;
  font-weight: 600;

  transition: background-color 0.15s ease, transform 0.1s ease;
}

.auth-submit:hover:not(:disabled) {
  background: var(--orange-dark);
}

.auth-submit:active:not(:disabled) {
  transform: translateY(1px);
}

.auth-submit:disabled {
  opacity: 0.75;
}

.button-spinner {
  display: none;
  width: 15px;
  height: 15px;

  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #FFFFFF;
  border-radius: 50%;

  animation: auth-spin 0.7s linear infinite;
}

.auth-submit.loading .button-spinner {
  display: block;
}

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

.text-button {
  padding: 0;
  border: 0;
  background: none;

  font-size: 12.5px;
  font-weight: 600;
  color: var(--orange);
}

.text-button:hover:not(:disabled) {
  text-decoration: underline;
}

.text-button:disabled {
  color: var(--muted-light);
}

.secondary-button {
  width: 100%;
  margin-top: 18px;
  padding: 11px 22px;

  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: transparent;

  font-size: 14px;
  font-weight: 600;
  color: var(--ink);

  transition: border-color 0.15s ease;
}

.secondary-button:hover {
  border-color: var(--muted);
}


/* ---------- Notes ---------- */

.security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  margin-top: 18px;

  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted-light);
}

.security-note svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.help-line {
  margin-top: 10px;
  font-size: 12.5px;
  text-align: center;
  color: var(--muted);
}

.help-line a,
.help-email {
  font-weight: 600;
  color: var(--orange);
}

.help-line a:hover,
.help-email:hover {
  text-decoration: underline;
}

.help-email {
  font-size: 15px;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;

  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-2);

  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}


/* ---------- Verification ---------- */

.otp-row {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin: 4px 0 18px;
}

.otp-box {
  flex: 1 1 0;
  min-width: 0;
  max-width: 46px;
  height: 54px;
  padding: 0;

  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);

  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
}

.otp-box:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 107, 34, 0.15);
}

.otp-box.error {
  border-color: var(--err);
}

.verify-meta {
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  color: var(--muted);
}

.verify-meta p {
  display: inline;
  margin-right: 4px;
}

.resend-status {
  display: block;
  min-height: 18px;
  margin-top: 6px;
  font-size: 12px;
}

.resend-status.success { color: var(--success); }
.resend-status.error   { color: var(--err); }


/* ---------- Welcome (JS redirects after 3s) ---------- */

.done-panel {
  text-align: center;
}

.redirect-message {
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--muted);
}

.welcome-progress {
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--line);
}

.welcome-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--orange);
  animation: auth-fill 3s linear forwards;
}

@keyframes auth-fill {
  to { width: 100%; }
}


/* ---------- Responsive ---------- */

@media (max-width: 480px) {

  .login-main {
    padding: 8px 16px 40px;
  }

  .auth-panel {
    padding: 28px 20px;
  }

  .otp-row {
    gap: 6px;
  }

  .otp-box {
    height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {

  .welcome-progress span {
    animation: none;
    width: 100%;
  }
}
