/* ── Component: Login page, auth redirect ──
 * Class prefix: login-
 */

/* ── Login Page ─────────────────────────────────────────────────────── */
.login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.login-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 50%, #0a1628 100%);
}
.login-bg-ambient {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(99,102,241,.12) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(139,92,246,.08) 0%, transparent 50%);
}

.login-card {
  position: relative;
  width: 420px; max-width: 90vw;
  padding: 40px 32px;
  text-align: center;
  border-radius: 20px;
}

.login-logo-area {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}

/* ── Login orbital animation (brand animation) ── */
.login-orb-system {
  position: relative;
  width: 90px;
  height: 90px;
}

.login-orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: login-orb-spin linear infinite;
}
.login-orb-ring-1 { width: 90px; height: 90px; border-color: rgba(167,139,250,0.12); animation-duration: 15s; }
.login-orb-ring-2 { width: 66px; height: 66px; border-color: rgba(244,114,182,0.15); animation-duration: 10s; animation-direction: reverse; }
.login-orb-ring-3 { width: 42px; height: 42px; border-color: rgba(52,211,153,0.2); animation-duration: 6s; }

@keyframes login-orb-spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.login-orb-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
  border-radius: 14px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  filter: drop-shadow(0 0 12px rgba(167,139,250,0.4));
  animation: login-orb-pulse 3s ease-in-out infinite;
  /* login-genie-spin 6s linear infinite — uncomment to enable 360 rotation */
  z-index: 2;
}

@keyframes login-orb-pulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(167,139,250,0.3)); }
  50% { filter: drop-shadow(0 0 20px rgba(167,139,250,0.6)); }
}

@keyframes login-genie-spin {
  from { transform: translate(-50%, -50%) rotateY(0deg); }
  to { transform: translate(-50%, -50%) rotateY(360deg); }
}

.login-sat-wrap {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: login-orb-spin linear infinite;
}

.login-sat-dot {
  border-radius: 50%;
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
}
.login-title {
  font-size: 1.6rem; font-weight: 700;
  background: linear-gradient(135deg, #e0e7ff, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin: 0;
}
.login-subtitle {
  font-size: 0.85rem; color: var(--color-text-secondary);
  margin: 0;
}

.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
  margin: 24px 0;
}

/* ── Intro video ── */
.login-video-wrap {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}
.login-video-wrap.expanded {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  border-radius: 0;
  border: none;
  z-index: 1001;
  cursor: default;
  background: #000;
}
.login-video-wrap.expanded .login-video {
  height: 100vh;
  height: 100dvh;
  aspect-ratio: auto;
  object-fit: contain;
}
.login-video {
  width: 100%;
  display: block;
  background: #000;
  aspect-ratio: 16/9;
}
.login-video-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.login-video-play:hover {
  background: rgba(255,255,255,0.25);
  transform: translate(-50%, -50%) scale(1.08);
}
.login-video-wrap.playing .login-video-play {
  display: none;
}
.login-video-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s;
}
.login-video-close:hover {
  background: rgba(0,0,0,0.7);
}
.login-video-wrap.expanded .login-video-close {
  display: flex;
}
.login-video-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
}
.login-video-backdrop.visible {
  display: block;
}

.login-cta {
  font-size: 0.9rem; color: var(--color-text-primary);
  margin: 0 0 20px;
}

.login-google-btn-wrap {
  display: flex; justify-content: center;
  min-height: 44px;
}

.login-or-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.login-or-divider::before,
.login-or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.08);
}

.login-ms-btn-wrap {
  display: flex; justify-content: center;
  min-height: 44px;
}
.login-ms-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  max-width: 300px;
  padding: 10px 16px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 4px;
  background: rgba(255,255,255,.04);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.login-ms-btn:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.2);
}
.login-ms-btn:active {
  background: rgba(255,255,255,.06);
}

.login-error {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #ef4444;
  padding: 8px 12px;
  background: rgba(239,68,68,.08);
  border-radius: 8px;
}

.login-invite-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: rgba(167,139,250,.08);
  border: 1px solid rgba(167,139,250,.2);
  font-size: 0.82rem;
  color: rgba(255,255,255,.85);
}
.login-invite-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}
.login-invite-banner strong {
  color: var(--color-accent, #a78bfa);
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  letter-spacing: 0.05em;
}

.login-footer {
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
  line-height: 1.5;
}
.login-footer a {
  color: var(--color-accent, #a78bfa);
  text-decoration: none;
  cursor: pointer;
}
.login-footer a:hover {
  text-decoration: underline;
}
.login-contact {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.3));
}
.login-contact a {
  color: var(--color-text-tertiary, rgba(255,255,255,.4));
  text-decoration: none;
}
.login-contact a:hover {
  color: var(--color-accent, #a78bfa);
  text-decoration: underline;
}

/* ── API Key Modal ─────────────────────────────────────────────────── */
.apikey-overlay {
  z-index: 200;
}
.apikey-modal {
  width: 420px; max-width: 90vw;
  padding: 32px;
  text-align: center;
  border-radius: 16px;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.apikey-icon {
  color: var(--color-accent, #a78bfa);
  margin-bottom: 12px;
}
.apikey-title {
  font-size: 1.15rem; font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 8px;
}
.apikey-desc {
  font-size: 0.8rem; color: var(--color-text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}
.apikey-input-wrap {
  position: relative;
}
.apikey-input {
  width: 100%; box-sizing: border-box;
  padding: 10px 40px 10px 14px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  color: var(--color-text-primary);
  font-size: 1rem;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  transition: border-color .15s;
}
.apikey-input:focus {
  border-color: var(--color-accent, #a78bfa);
}
.apikey-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--color-text-secondary);
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.apikey-error {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #ef4444;
  padding: 8px 12px;
  background: rgba(239,68,68,.08);
  border-radius: 8px;
  text-align: left;
}
.apikey-actions {
  margin-top: 16px;
}
.apikey-submit {
  width: 100%;
  padding: 10px 20px;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, #6C3BEE, #a78bfa);
  color: #fff;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.apikey-submit:disabled {
  opacity: .4; cursor: not-allowed;
}
.apikey-submit:not(:disabled):hover {
  opacity: .9;
}
.apikey-help {
  margin-top: 14px;
  font-size: 0.72rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
}
.apikey-help a {
  color: var(--color-accent, #a78bfa);
  text-decoration: none;
}
.apikey-help a:hover { text-decoration: underline; }

/* ── Legal Modals ─────────────────────────────────────────────────── */
.legal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: legalFadeIn .15s ease;
}
@keyframes legalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.legal-modal {
  width: 600px; max-width: 92vw;
  max-height: 80vh;
  border-radius: 16px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.legal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}
.legal-title {
  font-size: 1.15rem; font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}
.legal-close-btn {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.legal-close-btn:hover {
  background: rgba(255,255,255,.12);
  color: var(--color-text-primary);
}
.legal-content {
  padding: 16px 24px 24px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.07) transparent;
}
.legal-content::-webkit-scrollbar { width: 4px; }
.legal-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }
.legal-content h3 {
  font-size: 0.88rem; font-weight: 600;
  color: var(--color-text-primary);
  margin: 20px 0 6px;
}
.legal-content h3:first-of-type {
  margin-top: 8px;
}
.legal-content p {
  margin: 0 0 10px;
}
.legal-content ul {
  margin: 0 0 10px;
  padding-left: 20px;
}
.legal-content li {
  margin-bottom: 4px;
}
.legal-content a {
  color: var(--color-accent, #a78bfa);
  text-decoration: none;
}
.legal-content a:hover {
  text-decoration: underline;
}
.legal-updated {
  font-size: 0.75rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
  margin: 0 0 8px;
  font-style: italic;
}
.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  font-size: 0.82rem;
  line-height: 1.4;
}
.legal-table th,
.legal-table td {
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.1);
  text-align: left;
  vertical-align: top;
}
.legal-table th {
  background: rgba(255,255,255,.06);
  color: var(--color-text-secondary, rgba(255,255,255,.7));
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.legal-table td {
  color: var(--color-text-secondary, rgba(255,255,255,.55));
}
.legal-table a {
  color: var(--color-accent, #a78bfa);
  text-decoration: none;
}
.legal-table a:hover {
  text-decoration: underline;
}

/* ── User Menu ─────────────────────────────────────────────────────── */
.user-menu {
  position: relative;
  margin-left: 12px;
}
.user-menu-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  cursor: pointer;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-primary);
  font-weight: 600; font-size: 0.85rem;
  transition: border-color .15s;
}
.user-menu-btn:hover { border-color: var(--color-accent, #a78bfa); }
.user-menu-avatar {
  width: 100%; height: 100%;
  object-fit: cover;
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: 220px;
  padding: 12px 0;
  border-radius: 12px;
  z-index: 300;
}
.user-menu-name {
  padding: 4px 16px 0;
  font-size: 0.85rem; font-weight: 600;
  color: var(--color-text-primary);
}
.user-menu-email {
  padding: 2px 16px 8px;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 4px 0;
}
.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 16px;
  border: none; background: none;
  color: var(--color-text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}
.user-menu-item:hover {
  background: rgba(255,255,255,.04);
}
.user-menu-item--danger {
  color: #ef4444;
}
.user-menu-item--danger:hover {
  background: rgba(239,68,68,.08);
}

/* ── Touch feedback ── */
@media (hover: none) and (pointer: coarse) {
  .apikey-submit:active,
  .login-ms-btn:active {
    transform: scale(0.97);
    opacity: 0.85;
  }
}

/* ── Mobile bottom sheets ── */
@media (max-width: 480px) {
  .login-card {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    padding: 28px 24px calc(24px + var(--safe-bottom, 0px));
  }

  .login-title { font-size: 1.4rem; }
  .login-subtitle { font-size: 0.82rem; }

  .login-ms-btn {
    width: 100%;
    max-width: 100%;
  }

  .login-google-btn-wrap {
    width: 100%;
  }

  .apikey-modal {
    width: 100%;
    max-width: 100%;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    border-radius: 16px 16px 0 0;
    padding: 24px 20px calc(32px + var(--safe-bottom, 0px));
    animation: slide-up-sheet 0.25s ease-out;
  }

  .legal-modal {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(20px + var(--safe-bottom, 0px));
  }

  .login-divider { margin: 16px 0; }
  .login-footer a { padding: 4px 0; }
  .login-video-wrap { border-radius: 10px; }
  .login-video-wrap.expanded { width: 100vw; border-radius: 0; }
  .login-video-play { width: 48px; height: 48px; }
}

/* ── Extra small (≤ 375px) ── */
@media (max-width: 375px) {
  .login-card {
    padding: 24px 18px calc(20px + var(--safe-bottom, 0px));
  }

  .login-title { font-size: 1.25rem; }
  .login-subtitle { font-size: 0.78rem; }
  .login-cta { font-size: 0.82rem; }
  .login-or-divider { font-size: 0.7rem; margin: 12px 0; }
  .login-divider { margin: 14px 0; }
  .login-footer { font-size: 0.7rem; }
  .login-contact { font-size: 0.68rem; }

  .login-orb-system { width: 72px; height: 72px; }
}

@keyframes slide-up-sheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
