/* =============================================================
   LOGIN.CSS -- Login Page Styles
   Al Buraimi Ministry eServices Web Portal
   ============================================================= */

/* Text selection highlight */
::selection        { background: #f5a623; color: #101c4e; }
::-moz-selection   { background: #f5a623; color: #101c4e; }

/* --- Page Shell --- */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-light);
}

/* --- Top Identity Bar --- */
.login-topbar {
  background: var(--color-primary);
  padding: 0 var(--space-8);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(10, 18, 53, 0.3);
}

.login-topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  text-decoration: none;
}

.login-topbar__logo {
  height: 46px;
  width: auto;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.login-topbar__name {
  display: flex;
  flex-direction: column;
}

.login-topbar__name-en {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.2;
}

.login-topbar__name-ar {
  font-family: var(--font-arabic);
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.2;
}

.login-topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.login-topbar__back {
  color: rgba(255, 255, 255, 0.75);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  transition: color var(--transition-fast);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.login-topbar__back:hover {
  color: var(--color-white);
  background: rgba(255, 255, 255, 0.08);
}

/* --- Main 2-column layout --- */
.login-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 560px;
  min-height: calc(100vh - 64px);
}

/* --- Left Panel: decorative --- */
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-12);
  position: relative;
  overflow: hidden;
}

/* Animated background image */
.login-panel__bg {
  position: absolute;
  inset: 0;
  background: url('../../assets/images/login-image.jpg') center / cover no-repeat;
  z-index: 0;
  animation: bgKenBurns 30s ease-in-out infinite;
  transform-origin: center;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Ken Burns: start & end at same position so loop is seamless — no snap */
@keyframes bgKenBurns {
  0%   { transform: scale(1.08) translate(0,    0);      }
  25%  { transform: scale(1.10) translate(-1%,  -0.5%);  }
  50%  { transform: scale(1.09) translate(-1.5%, 0.4%);  }
  75%  { transform: scale(1.10) translate(-0.5%, -0.8%); }
  100% { transform: scale(1.08) translate(0,    0);      }
}

/* Dark gradient overlay so text stays readable */
.login-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      135deg,
      rgba(7, 16, 42, 0.60) 0%,
      rgba(16, 28, 78, 0.52) 55%,
      rgba(14, 34, 82, 0.46) 100%
    );
  z-index: 1;
}

/* Decorative ring accent */
.login-panel::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  top: -130px;
  right: -170px;
  border-radius: 50%;
  border: 1px solid rgba(245, 166, 35, 0.18);
  z-index: 2;
  pointer-events: none;
}

/* All panel content sits above the overlay (z-index >= 3) */
.login-panel__logo {
  width: 180px;
  height: auto;
  object-fit: contain;
  border-radius: 20px;
  margin-bottom: var(--space-8);
  margin-left: auto;
  margin-right: auto;
  display: block;
  position: relative;
  z-index: 3;
  filter: drop-shadow(0 6px 32px rgba(0,0,0,0.65));
  box-shadow: 0 0 0 6px rgba(255,255,255,0.10);
}

.login-panel__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.75rem);
  font-weight: 800;
  color: var(--color-white);
  line-height: 1.25;
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 3;
  text-align: center;
  text-shadow: 0 2px 20px rgba(0,0,0,0.45);
}

.login-panel__title span {
  color: var(--color-accent-orange);
  display: block;
  font-size: clamp(2rem, 3.5vw, 3rem);
}

.login-panel__subtitle {
  font-size: var(--text-base);
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.7;
  max-width: 400px;
  margin-bottom: var(--space-10);
  position: relative;
  z-index: 3;
  text-align: center;
}

.login-panel__features {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
  z-index: 3;
  align-items: flex-start;
  background: rgba(0,0,0,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
}

.login-panel__feature {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--text-sm);
  font-weight: 500;
}

.login-panel__feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  backdrop-filter: blur(4px);
}

.login-panel__feature-icon--green  { background: rgba(46,189,154,0.25); }
.login-panel__feature-icon--orange { background: rgba(245,166,35,0.25); }
.login-panel__feature-icon--purple { background: rgba(107,63,160,0.25); }

/* --- Right Panel: form --- */
.login-form-panel {
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-12);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideInRight 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes slideInRight {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* --- Login Card --- */
.login-card {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  width: 100%;
  max-width: 100%;
  border: none;
}

.login-card__header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-card__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-accent-green);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

.login-card__eyebrow::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent-green);
}

.login-card__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.login-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

/* Progress steps */
.login-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.login-progress__step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

.login-progress__dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-white);
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.login-progress__step.active .login-progress__dot {
  border-color: var(--color-accent-orange);
  background: var(--color-accent-orange);
  color: var(--color-white);
}

.login-progress__step.done .login-progress__dot {
  border-color: var(--color-accent-green);
  background: var(--color-accent-green);
  color: var(--color-white);
}

.login-progress__step.active { color: var(--color-primary); }
.login-progress__step.done   { color: var(--color-accent-green); }

.login-progress__line {
  flex: 1;
  height: 2px;
  background: var(--color-border);
  border-radius: 2px;
  transition: background var(--transition-base);
}

.login-progress__line.done { background: var(--color-accent-green); }

/* Step containers */
.login-step { display: none; }
.login-step.active {
  display: block;
  animation: stepFadeIn 0.3s ease;
}

@keyframes stepFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-step__label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.login-step__label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Phone input with +968 prefix */
.phone-input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  margin-bottom: var(--space-4);
  background: var(--color-white);
}

.phone-input-wrap:focus-within {
  border-color: var(--color-accent-orange);
  box-shadow: 0 0 0 3px rgba(245,166,35,0.15);
}

.phone-input-wrap.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(231,76,60,0.12);
}

.phone-prefix {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  border-right: 1.5px solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
  height: 48px;
  flex-shrink: 0;
  background: #f8f9fc;
}

.phone-prefix__flag { font-size: 18px; }

.phone-input {
  flex: 1;
  height: 48px;
  padding: 0 var(--space-4);
  border: none;
  outline: none;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-primary);
  background: transparent;
  font-family: var(--font-body);
}

.phone-input::placeholder {
  color: var(--color-text-muted);
  font-weight: 400;
}

/* OTP input */
.login-input-wrap {
  position: relative;
  margin-bottom: var(--space-4);
}

.login-input {
  width: 100%;
  height: 56px;
  padding: 0 var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-white);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  font-family: var(--font-body);
  letter-spacing: 0.35em;
  text-align: center;
}

.login-input:focus {
  border-color: var(--color-accent-orange);
  box-shadow: 0 0 0 3px rgba(245,166,35,0.15);
}

.login-input.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(231,76,60,0.12);
}

/* OTP info banner */
.otp-info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: rgba(46,189,154,0.08);
  border: 1px solid rgba(46,189,154,0.25);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: #1a7a65;
  line-height: 1.5;
}

.otp-info__icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.otp-info strong { font-weight: 700; }

/* Error message */
.login-error {
  display: none;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-error);
  font-weight: 500;
  margin-top: calc(var(--space-2) * -1);
  margin-bottom: var(--space-3);
}

.login-error.visible { display: flex; }

/* Buttons */
.login-btn {
  width: 100%;
  height: 50px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all var(--transition-base);
  margin-bottom: var(--space-3);
  position: relative;
}

.login-btn--orange {
  background: var(--color-accent-orange);
  color: var(--color-white);
  box-shadow: 0 4px 16px rgba(245,166,35,0.35);
}

.login-btn--orange:hover {
  background: #e0961f;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(245,166,35,0.45);
}

.login-btn--green {
  background: var(--color-accent-green);
  color: var(--color-white);
  box-shadow: 0 4px 16px rgba(46,189,154,0.35);
}

.login-btn--green:hover {
  background: #26a689;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(46,189,154,0.45);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.login-btn.loading {
  color: transparent;
  pointer-events: none;
}

.login-btn.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Back button */
.login-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color var(--transition-fast);
  margin-bottom: var(--space-5);
}

.login-back:hover { color: var(--color-primary); }

/* Card footer */
.login-card__footer {
  text-align: center;
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.login-card__footer p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.login-card__footer a {
  color: var(--color-primary-light);
  font-weight: 600;
  text-decoration: none;
}

.login-card__footer a:hover { text-decoration: underline; }

/* Lang toggle in topbar */
.login-lang {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.9rem;
  cursor: pointer;
  color: var(--color-white);
  font-size: var(--text-sm);
  font-weight: 500;
  user-select: none;
  transition: background var(--transition-base);
}

.login-lang:hover { background: rgba(255,255,255,0.18); }
.login-lang .lang-option.active { color: var(--color-accent-orange); font-weight: 700; }
.login-lang .lang-divider { color: rgba(255,255,255,0.4); }

/* --- Responsive --- */
@media (max-width: 900px) {
  .login-main { grid-template-columns: 1fr; }
  .login-panel { display: none; }
  .login-form-panel {
    min-height: calc(100vh - 64px);
    padding: var(--space-8) var(--space-6);
    justify-content: flex-start;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .login-topbar { padding: 0 var(--space-4); }
  .login-topbar__name { display: none; }
  .login-form-panel { padding: var(--space-6) var(--space-4); background: var(--color-white); }
}

/* RTL */
[dir="rtl"] .phone-prefix {
  border-right: none;
  border-left: 1.5px solid var(--color-border);
}
[dir="rtl"] .login-panel { align-items: center; text-align: center; }
[dir="rtl"] .login-panel__features { align-items: flex-start; }
[dir="rtl"] .login-panel__feature { flex-direction: row-reverse; }
