/* ── Login Modal ─────────────────────────────────────────────────────────── */

/* Backdrop */
.lm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(10, 24, 45, 0.82);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lm-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Card */
.lm-card {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.34, 1.36, 0.64, 1);
}

.lm-backdrop.is-open .lm-card {
  transform: translateY(0) scale(1);
}

/* Card header (UGLE Blue strip with shield) */
.lm-card-header {
  background: linear-gradient(135deg, var(--ugle-blue) 0%, var(--ugle-blue-mid) 100%);
  padding: 1.75rem 1.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lm-header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.lm-shield {
  width: 40px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.lm-header-wordmark {
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255,255,255,0.25);
  padding-left: 0.85rem;
  font-family: 'Barlow', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.82);
  line-height: 1.45;
}

.lm-close {
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  font-size: 1.1rem;
  transition: background 0.15s;
  flex-shrink: 0;
}
.lm-close:hover { background: rgba(255,255,255,0.22); color: #fff; }

/* Card body */
.lm-body {
  padding: 1.75rem;
}

/* State transitions */
.lm-state {
  animation: lm-fadeIn 0.22s ease;
}
.lm-state.lm-hidden { display: none; }

@keyframes lm-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Typography */
.lm-title {
  font-family: 'Barlow', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ugle-blue);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.lm-subtitle {
  font-size: 0.92rem;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 1.4rem;
}

/* Form fields */
.lm-field {
  margin-bottom: 1rem;
}

.lm-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin-bottom: 0.4rem;
}

.lm-field input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: 'Barlow', sans-serif;
  font-size: 0.95rem;
  color: var(--text-dark);
  background: var(--off-white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.lm-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(107,127,153,0.15);
  background: var(--white);
}

.lm-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Primary button */
.lm-btn {
  width: 100%;
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-family: 'Barlow', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.lm-btn--primary {
  background: var(--ugle-blue);
  color: var(--white);
}
.lm-btn--primary:hover:not(:disabled) { background: var(--ugle-blue-mid); }
.lm-btn--primary:disabled { opacity: 0.6; cursor: wait; }

/* Spinner */
.lm-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lm-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes lm-spin { to { transform: rotate(360deg); } }

/* Divider */
.lm-divider {
  text-align: center;
  margin: 1.1rem 0 0.75rem;
  font-size: 0.78rem;
  color: var(--text-light);
  position: relative;
}
.lm-divider::before, .lm-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.lm-divider::before { left: 0; }
.lm-divider::after  { right: 0; }

/* Ghost link button */
.lm-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: 'Barlow', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.lm-link-btn:hover { color: var(--accent-mid); }

/* Success / error icons */
.lm-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.lm-icon--success { background: rgba(34,197,94,0.12); color: #16a34a; }
.lm-icon--error   { background: rgba(239,68,68,0.1);  color: #dc2626; }
.lm-icon--email   {
  background: rgba(107,127,153,0.1);
  color: var(--accent);
  font-size: 1.3rem;
}

/* Hint text */
.lm-hint {
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.6;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

/* Error message inline */
.lm-error-inline {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 6px;
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
  color: #b91c1c;
  margin-bottom: 1rem;
  display: none;
}
.lm-error-inline.is-visible { display: block; }

/* Footer note */
.lm-footer-note {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
  margin-top: 1.1rem;
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 480px) {
  .lm-backdrop {
    padding: 0;
    align-items: flex-end;
    /* Respect the visual viewport (keyboard open etc.) */
    align-items: safe flex-end;
  }
  .lm-card {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    /* Never taller than 88% of the visible viewport */
    max-height: 88svh;
    max-height: 88vh; /* fallback for older browsers */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Clear phone home-indicator notch */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .lm-card-header { padding: 1.25rem 1.25rem 1.1rem; }
  .lm-body { padding: 1.25rem; }
  .lm-field-row { grid-template-columns: 1fr; gap: 0; }
}
