/* ============================================================
   Authentication UI — login, user menu, modals
   ============================================================ */

/* ── Nav auth container ───────────────────────────────────────── */

.nav-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  margin-right: 12px;
  min-width: 140px;
  justify-content: flex-end;
}

.auth-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.auth-icon--xs {
  width: 12px;
  height: 12px;
}

/* ── Login button ─────────────────────────────────────────────── */

.auth-btn--login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  color: var(--heading);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.auth-btn--login:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.35);
}

/* ── User menu (logged in) ────────────────────────────────────── */

.auth-user {
  position: relative;
}

.auth-user__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px 0 4px;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  color: var(--heading);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.auth-user__btn:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.35);
}

.auth-user__avatar {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 6px;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.auth-user__name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Dropdown menu ────────────────────────────────────────────── */

.auth-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  padding: 6px;
  z-index: 100;
}
.auth-dropdown[hidden] { display: none; }

.auth-dropdown__header {
  padding: 10px 10px 8px;
}

.auth-dropdown__email {
  display: block;
  font-size: 12px;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-dropdown__role {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 4px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.auth-dropdown__role.is-team {
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
}

.auth-dropdown__sep {
  height: 1px;
  background: rgba(148, 163, 184, 0.15);
  margin: 4px 0;
}

.auth-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-dropdown__item:hover {
  background: rgba(148, 163, 184, 0.12);
}
.auth-dropdown__item--danger {
  color: #f87171;
}
.auth-dropdown__item--danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

/* ── Auth modals ──────────────────────────────────────────────── */

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: authFadeIn 0.2s ease-out;
}
.auth-modal[hidden] { display: none; }

@keyframes authFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes authSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-modal .modal-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
              rgba(59,130,246,0.10) 0%,
              rgba(0,0,0,0.65) 60%);
  backdrop-filter: blur(8px) saturate(140%);
}

.auth-modal .modal-content--auth {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 36px 32px 28px;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 20px;
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.06) inset,
    0 30px 80px -20px rgba(0,0,0,0.55),
    0 0 0 1px rgba(59,130,246,0.08);
  animation: authSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* Decorative top gradient accent */
.auth-modal .modal-content--auth::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(59,130,246,0.6) 25%,
    rgba(139,92,246,0.7) 50%,
    rgba(6,182,212,0.6) 75%,
    transparent 100%);
}

.auth-modal .modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.auth-modal .modal-close:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--heading);
  transform: rotate(90deg);
}

/* Brand / Logo block at top of modal */
.auth-modal__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.auth-modal__logo {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg,
              rgba(59,130,246,0.18),
              rgba(139,92,246,0.18),
              rgba(6,182,212,0.18));
  border: 1px solid rgba(99,102,241,0.25);
  color: #93c5fd;
  box-shadow:
    0 0 30px rgba(99,102,241,0.25),
    0 1px 0 0 rgba(255,255,255,0.06) inset;
  position: relative;
}
.auth-modal__logo::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 18px;
  background: linear-gradient(135deg,
              rgba(59,130,246,0.4),
              rgba(139,92,246,0.4),
              rgba(6,182,212,0.4));
  z-index: -1;
  filter: blur(8px);
  opacity: 0.5;
}

.auth-modal__head {
  margin-bottom: 24px;
  text-align: center;
}
.auth-modal__head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--heading), #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-modal__head p {
  margin: 10px auto 0;
  max-width: 320px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.auth-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: 0.02em;
}

/* Input with icon prefix */
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.auth-input-icon {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.18s;
}
.auth-input-wrap:focus-within .auth-input-icon {
  color: var(--accent1, #3b82f6);
}

.auth-field input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  background: var(--surface2);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  color: var(--heading);
  font-size: 14px;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.auth-field input::placeholder {
  color: var(--muted);
}
.auth-field input:hover:not(:focus) {
  border-color: rgba(148, 163, 184, 0.35);
}
.auth-field input:focus {
  outline: none;
  border-color: rgba(59,130,246,0.5);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
  background: var(--surface);
}
.auth-field small {
  font-size: 11px;
  color: var(--muted);
  padding-left: 2px;
}

.auth-field--actions {
  margin-top: 8px;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  color: var(--heading);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, opacity 0.18s, transform 0.12s;
}
.auth-btn:hover {
  background: rgba(148, 163, 184, 0.12);
}
.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.auth-btn--primary {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  border: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow:
    0 6px 20px -6px rgba(99,102,241,0.55),
    0 1px 0 0 rgba(255,255,255,0.18) inset;
  position: relative;
  overflow: hidden;
}
.auth-btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.16), transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
}
.auth-btn--primary:hover {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  opacity: 1;
  box-shadow:
    0 8px 28px -6px rgba(99,102,241,0.7),
    0 1px 0 0 rgba(255,255,255,0.22) inset;
}
.auth-btn--primary:hover::after { opacity: 1; }

/* Microsoft OAuth button */
.auth-btn--microsoft {
  width: 100%;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #8c8c8c;
  border-radius: 4px;
  color: #5e5e5e;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.auth-btn--microsoft:hover {
  background: #f8f8f8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.auth-btn--microsoft:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.auth-btn--microsoft .microsoft-logo {
  flex-shrink: 0;
}
.auth-btn--microsoft .btn-loader {
  display: inline-flex;
  align-items: center;
}
.auth-btn--microsoft .auth-spinner {
  border-color: rgba(0,0,0,0.2);
  border-top-color: #5e5e5e;
}

[data-theme="light"] .auth-btn--microsoft {
  background: #fff;
}

/* Spinner for loading state */
.auth-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: authSpin 0.7s linear infinite;
  display: inline-block;
}
@keyframes authSpin {
  to { transform: rotate(360deg); }
}

.auth-error,
.auth-success {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}
.auth-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}
.auth-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}
.auth-error[hidden],
.auth-success[hidden] { display: none; }

.auth-link {
  text-align: center;
  margin-top: 4px;
}
.auth-link a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.18s;
  font-weight: 500;
}
.auth-link a:hover {
  color: #93c5fd;
}

/* ── Light theme ──────────────────────────────────────────────── */

[data-theme="light"] .auth-modal .modal-overlay {
  background: radial-gradient(ellipse at center,
              rgba(59,130,246,0.08) 0%,
              rgba(0,0,0,0.35) 60%);
}
[data-theme="light"] .auth-modal .modal-content--auth {
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.6) inset,
    0 30px 80px -20px rgba(0,0,0,0.18),
    0 0 0 1px rgba(59,130,246,0.06);
}
[data-theme="light"] .auth-modal__head h2 {
  background: linear-gradient(90deg, #0f172a, #475569);
  -webkit-background-clip: text;
  background-clip: text;
}
[data-theme="light"] .auth-modal__logo {
  color: #3b82f6;
}
[data-theme="light"] .auth-link a:hover {
  color: #2563eb;
}
[data-theme="light"] .auth-error {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
}
[data-theme="light"] .auth-success {
  background: rgba(16, 185, 129, 0.08);
  color: #059669;
}
[data-theme="light"] .auth-dropdown {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* ── Access denied page ───────────────────────────────────────── */

.access-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px 20px;
}

.access-denied__icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.access-denied h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--heading);
}

.access-denied p {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.access-denied .auth-btn--primary {
  margin-top: 24px;
  width: auto;
  padding: 0 32px;
}

.access-denied__hint {
  margin-top: 16px;
  font-size: 13px;
}

.access-denied__hint a {
  color: var(--accent1);
  text-decoration: none;
}
.access-denied__hint a:hover {
  text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 600px) {
  .auth-user__name {
    display: none;
  }
  .auth-modal .modal-content--auth {
    padding: 20px;
  }
}

/* ── Mobile menu auth ───────────────────────────────────────────── */

.nav-mobile-menu__auth {
  flex: 1;
}
.nav-mobile-menu__auth .auth-btn--login {
  width: 100%;
  justify-content: center;
}
.nav-mobile-menu__auth .auth-user {
  width: 100%;
}
.nav-mobile-menu__auth .auth-user__btn {
  width: 100%;
  justify-content: flex-start;
}
.nav-mobile-menu__auth .auth-user__name {
  display: block;
  max-width: none;
}
.nav-mobile-menu__auth .auth-dropdown {
  position: static;
  display: none;
  width: 100%;
  margin-top: 8px;
  box-shadow: none;
  border: 1px solid var(--border);
}
.nav-mobile-menu__auth .auth-user.is-dropdown-open .auth-dropdown {
  display: block;
}
