/**
 * ElectroSync — sliding Sign In / Sign Up card (system blue)
 */

/* Reset-password fields: eye button sits inside the input */
#forgotPasswordModal .password-field {
  position: relative;
}

#forgotPasswordModal .password-field .form-control {
  padding-right: 2.75rem;
}

#forgotPasswordModal .password-toggle-btn {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: #64748b;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
}

#forgotPasswordModal .password-toggle-btn:hover,
#forgotPasswordModal .password-toggle-btn:focus-visible {
  color: #0948a7;
  background: #eff6ff;
  outline: none;
}

.login-lock-notice {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 0.85rem;
  text-align: left;
}

.login-lock-notice strong {
  display: block;
  margin-bottom: 0.2rem;
  color: #9a3412;
}

.login-lock-notice #loginLockCountdown {
  display: block;
  margin-top: 0.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.modal-auth-dialog {
  max-width: 920px;
  width: calc(100% - 1.5rem);
}

.modal-auth-dialog .modal-content {
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.auth-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 20;
  background: #1e73ff !important;
  border-radius: 50%;
  opacity: 1;
  padding: 0;
  width: 2.15rem;
  height: 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background-image: none !important;
  box-shadow: none;
  transition: background-color 0.18s ease;
}

.auth-modal-close::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  background: #ffffff;
  border-radius: 999px;
  transform: translate(-50%, -50%) rotate(45deg);
  transform-origin: 50% 50%;
  transition: transform 0.28s ease;
}

.auth-modal-close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  background: #ffffff;
  border-radius: 999px;
  transform: translate(-50%, -50%) rotate(-45deg);
  transform-origin: 50% 50%;
  transition: transform 0.28s ease;
}

.auth-modal-close:hover {
  background: #2a7eff !important;
  border-color: rgba(255, 255, 255, 0.34);
}

/* Animate only the center X, keep button fixed */
.auth-modal-close:hover::before {
  transform: translate(-50%, -50%) rotate(225deg);
}

.auth-modal-close:hover::after {
  transform: translate(-50%, -50%) rotate(135deg);
}

.auth-modal-close:active {
  transform: none !important;
}

.auth-slide-card {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(9, 72, 167, 0.18), 0 8px 24px rgba(0, 0, 0, 0.08);
  background: #fff;
}

.auth-slide-inner {
  display: flex;
  position: relative;
  min-height: 540px;
}

.auth-pane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.75rem;
  background: #fff;
}

.auth-pane-inner {
  width: 100%;
  max-width: 340px;
}

/* Desktop: form content fades/slides with the blue panel (horizontal) */
@media (min-width: 768px) {
  .auth-slide-card .auth-pane-inner {
    transition:
      opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .auth-slide-card:not(.auth-mode-signup) .auth-pane-signin .auth-pane-inner {
    opacity: 1;
    transform: translateX(0);
  }

  .auth-slide-card:not(.auth-mode-signup) .auth-pane-signup .auth-pane-inner {
    opacity: 0;
    transform: translateX(32px);
    pointer-events: none;
  }

  .auth-slide-card.auth-mode-signup .auth-pane-signin .auth-pane-inner {
    opacity: 0;
    transform: translateX(-32px);
    pointer-events: none;
  }

  .auth-slide-card.auth-mode-signup .auth-pane-signup .auth-pane-inner {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Mobile: one-shot enter animation (JS adds .auth-form-enter-anim when switching) */
@keyframes authFormEnterMobile {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-form-enter-anim {
  animation: authFormEnterMobile 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .auth-slide-card .auth-pane-inner,
  .auth-slide-overlay {
    transition: none !important;
  }

  .auth-form-enter-anim {
    animation: none !important;
  }
}

.auth-pane-inner .auth-brand-logo {
  height: 48px;
  width: auto;
  display: block;
  margin: 0 auto 0.75rem;
}

.auth-pane-inner h2 {
  font-size: 1.65rem;
  font-weight: 700;
  text-align: center;
  color: #0f172a;
  margin-bottom: 0.35rem;
}

.auth-pane-inner .auth-sub {
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 1.25rem;
}

.auth-pane-inner .form-control {
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.auth-pane-inner .form-label {
  font-size: 0.8rem;
}

.auth-btn-primary {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.65rem 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  background: linear-gradient(135deg, #0948a7 0%, #2563eb 100%);
  color: #fff !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(9, 72, 167, 0.35);
  color: #fff !important;
}

.auth-slide-overlay {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  z-index: 4;
  background: linear-gradient(145deg, #0948a7 0%, #1d4ed8 45%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  padding: 2rem 1.5rem;
  transition: left 0.65s cubic-bezier(0.65, 0, 0.35, 1);
  border-radius: 0;
}

.auth-slide-card.auth-mode-signup .auth-slide-overlay {
  left: 0;
}

.auth-overlay-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.auth-overlay-panel h3 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.75rem;
}

.auth-overlay-panel p {
  font-size: 0.95rem;
  opacity: 0.92;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  max-width: 280px;
}

.auth-ghost-btn {
  border: 2px solid rgba(255, 255, 255, 0.95);
  color: #fff !important;
  background: transparent;
  border-radius: 12px;
  padding: 0.55rem 2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease;
}

.auth-ghost-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff !important;
}

/* Show overlay CTA for “sign up” when panel is on the right (default) */
.auth-slide-card:not(.auth-mode-signup) .auth-overlay-signup-cta {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.auth-slide-card:not(.auth-mode-signup) .auth-overlay-signin-cta {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-slide-card.auth-mode-signup .auth-overlay-signup-cta {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-slide-card.auth-mode-signup .auth-overlay-signin-cta {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.auth-overlay-brand {
  height: 40px;
  width: auto;
  margin-bottom: 1rem;
  filter: brightness(0) invert(1);
}

#loginModalContextMessage {
  position: relative;
  z-index: 5;
  margin: 0 1rem 0.5rem;
  border-radius: 10px;
}

/* Tablet / narrow: stack vertically + slide blue panel up/down */
@media (max-width: 767.98px) {
  .modal-auth-dialog {
    margin: 0.35rem auto;
    max-height: calc(100vh - 0.75rem);
    max-height: calc(100dvh - 0.75rem);
  }

  .auth-slide-inner {
    display: block;
    position: relative;
    /* Use most of the viewport so signup fields fit without inner scroll */
    height: min(96vh, 720px);
    min-height: min(96vh, 720px);
    height: min(96dvh, 720px);
    min-height: min(96dvh, 720px);
  }

  .auth-pane {
    flex: none;
    width: 100%;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 2;
    padding: 1.1rem 1rem 0.85rem;
    background: #fff;
  }

  /* Sign In: white ~72%, blue band ~28% */
  .auth-slide-card:not(.auth-mode-signup) .auth-pane-signin {
    display: flex;
    top: 0;
    height: 72%;
    max-height: 72%;
    align-items: flex-start;
    justify-content: center;
    border-radius: 24px 24px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-slide-card:not(.auth-mode-signup) .auth-pane-signup {
    display: none !important;
  }

  /* Sign Up: compact blue ~26% top, form ~74% — no scrolling inside form */
  .auth-slide-card.auth-mode-signup .auth-pane-signup {
    display: flex;
    flex-direction: row;
    top: 26%;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    max-height: 74%;
    align-items: flex-start;
    justify-content: center; /* center form horizontally */
    border-radius: 0 0 24px 24px;
    padding: 0.45rem 1.1rem 0.5rem;
    overflow: visible;
    overflow-y: visible;
  }

  /* Full usable width inside pane, still visually centered */
  .auth-pane-signup .auth-pane-inner {
    width: 100%;
    max-width: min(100%, 380px);
    margin-left: auto;
    margin-right: auto;
  }

  .auth-slide-card.auth-mode-signup .auth-pane-signin {
    display: none !important;
  }

  /* Blue panel — animates top; shorter in signup mode to free space for fields */
  .auth-slide-overlay {
    left: 0 !important;
    width: 100% !important;
    transition: top 0.65s cubic-bezier(0.65, 0, 0.35, 1),
      height 0.35s ease;
    z-index: 3;
  }

  .auth-slide-card:not(.auth-mode-signup) .auth-slide-overlay {
    height: 28%;
    min-height: 140px;
    max-height: 200px;
    top: 72%;
    bottom: auto;
    border-radius: 16px 16px 0 0;
  }

  .auth-slide-card.auth-mode-signup .auth-slide-overlay {
    height: 26%;
    min-height: 112px;
    max-height: 150px;
    top: 0;
    border-radius: 0 0 16px 16px;
  }

  .auth-slide-overlay .auth-overlay-panel {
    position: absolute;
    inset: 0;
    padding: 0.65rem 1rem;
    justify-content: center;
  }

  .auth-overlay-panel h3 {
    font-size: 1.35rem;
  }

  .auth-overlay-panel p {
    font-size: 0.85rem;
    margin-bottom: 0.65rem;
  }

  /* Signup mode: tighter blue “Welcome back” strip */
  .auth-slide-card.auth-mode-signup .auth-overlay-signin-cta .auth-overlay-brand {
    height: 28px;
    margin-bottom: 0.25rem;
  }

  .auth-slide-card.auth-mode-signup .auth-overlay-signin-cta h3 {
    font-size: 1.1rem;
    margin-bottom: 0.15rem;
  }

  .auth-slide-card.auth-mode-signup .auth-overlay-signin-cta p {
    font-size: 0.72rem;
    line-height: 1.25;
    margin-bottom: 0.35rem;
    max-width: 100%;
  }

  .auth-slide-card.auth-mode-signup .auth-overlay-signin-cta .auth-ghost-btn {
    padding: 0.3rem 1rem;
    font-size: 0.7rem;
  }

  /* Sign-in mode bottom strip: compact “Hello / SIGN UP” */
  .auth-slide-card:not(.auth-mode-signup) .auth-overlay-signup-cta .auth-overlay-brand {
    height: 30px;
    margin-bottom: 0.3rem;
  }

  .auth-slide-card:not(.auth-mode-signup) .auth-overlay-signup-cta h3 {
    font-size: 1.15rem;
    margin-bottom: 0.2rem;
  }

  .auth-slide-card:not(.auth-mode-signup) .auth-overlay-signup-cta p {
    font-size: 0.75rem;
    line-height: 1.25;
    margin-bottom: 0.4rem;
  }

  .auth-slide-card:not(.auth-mode-signup) .auth-overlay-signup-cta .auth-ghost-btn {
    padding: 0.32rem 1rem;
    font-size: 0.7rem;
  }

  /* Sign-up form: hide duplicate logo + subtitle (blue panel already branded) */
  .auth-pane-signup .auth-brand-logo,
  .auth-pane-signup .auth-sub {
    display: none;
  }

  .auth-pane-signup .auth-pane-inner h2 {
    font-size: 1.2rem;
    margin-bottom: 0.35rem;
    margin-top: 0;
  }

  .auth-pane-signup .login-form .mb-2 {
    margin-bottom: 0.3rem !important;
  }

  .auth-pane-signup .login-form .mb-3 {
    margin-bottom: 0.35rem !important;
  }

  .auth-pane-signup .form-label {
    font-size: 0.7rem;
    margin-bottom: 0.1rem;
  }

  .auth-pane-signup .form-control {
    padding: 0.32rem 0.55rem;
    font-size: 16px; /* iOS: avoid zoom */
    min-height: 2.2rem;
    line-height: 1.25;
  }

  .auth-pane-signup .auth-btn-primary {
    padding: 0.42rem 0.65rem;
    font-size: 0.72rem;
    margin-top: 0.1rem;
  }

  .auth-pane-signup .password-toggle-icon {
    bottom: 8px !important;
  }

  .auth-pane-signup .text-center.small {
    margin-top: 0.35rem !important;
    margin-bottom: 0 !important;
    font-size: 0.72rem;
  }
}

/* Very small phones — even tighter signup */
@media (max-width: 380px) {
  .auth-pane-inner h2 {
    font-size: 1.25rem;
  }

  .auth-slide-inner {
    height: min(97dvh, 680px);
    min-height: min(97dvh, 680px);
  }

  .auth-slide-card.auth-mode-signup .auth-slide-overlay {
    min-height: 100px;
    max-height: 132px;
    height: 24%;
  }

  .auth-slide-card.auth-mode-signup .auth-pane-signup {
    top: 24%;
    max-height: 76%;
    padding: 0.35rem 0.75rem 0.4rem;
  }

  .auth-slide-card.auth-mode-signup .auth-overlay-signin-cta p {
    display: none;
  }

  .auth-pane-signup .login-form .mb-2 {
    margin-bottom: 0.22rem !important;
  }

  .auth-pane-signup .form-control {
    min-height: 2.05rem;
    padding: 0.28rem 0.5rem;
  }
}
