/* Auth Modal — styled to match the setup card */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Glass card */
.auth-modal {
  position: relative;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--primary-accent) 6%, rgba(255, 255, 255, 0.04)),
    color-mix(in srgb, var(--surface) 30%, rgba(255, 255, 255, 0.02)) 50%,
    color-mix(in srgb, var(--primary-deep) 8%, rgba(255, 255, 255, 0.01)));
  background-color: color-mix(in srgb, var(--surface) 40%, rgba(0, 0, 0, 0.5));
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border-radius: 24px;
  padding: 32px;
  width: 90%;
  max-width: 420px;
  margin: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  transform: translateY(30px) scale(0.97);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;

  --x: 50%;
  --y: 50%;
  --glow-size: 300px;
}

.auth-modal-overlay.active .auth-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Radial glow follow */
.auth-modal::before {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  border-radius: 20px;
  background: radial-gradient(
    var(--glow-size) circle at var(--x, 50%) var(--y, 50%),
    color-mix(in srgb, var(--primary-accent) 12%, transparent) 0%,
    color-mix(in srgb, var(--primary-accent) 4%, transparent) 30%,
    transparent 65%
  );
  opacity: 0.5;
  transition: opacity 180ms ease-out;
  z-index: 0;
}

/* Conic border glow on hover */
.auth-modal::after {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  border-radius: 25px;
  background: conic-gradient(
    from 180deg at var(--x, 50%) var(--y, 50%),
    var(--primary-accent),
    color-mix(in srgb, var(--primary-accent) 70%, var(--primary-deep) 30%),
    var(--primary-deep),
    color-mix(in srgb, var(--primary-accent) 70%, var(--primary-deep) 30%),
    var(--primary-accent)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  padding: 1px;
  opacity: 0;
  transition: opacity 220ms ease-out;
  will-change: opacity;
}

.auth-modal:hover::after {
  opacity: 0.3;
}

.auth-modal > * {
  position: relative;
  z-index: 1;
}

/* Close button */
.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  padding: 7px;
  border-radius: 10px;
  transition: background 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.auth-modal-close:hover {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  color: var(--text);
}

/* Title — always visible, gradient text */
.auth-modal-title {
  margin: 0 0 6px 0;
  color: transparent;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Form */
.auth-modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.auth-field input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 70%, rgba(0, 0, 0, 0.3));
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-accent) 15%, transparent);
}

.auth-field input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

/* Error / Success */
.auth-error {
  background: color-mix(in srgb, #dc2626 12%, transparent);
  border: 1px solid color-mix(in srgb, #dc2626 35%, transparent);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  display: none;
}

.auth-error.show {
  display: block;
}

.auth-success {
  background: color-mix(in srgb, #16a34a 12%, transparent);
  border: 1px solid color-mix(in srgb, #16a34a 35%, transparent);
  color: #86efac;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  display: none;
}

.auth-success.show {
  display: block;
}

/* Mode subtitle */
.auth-modal-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px 0;
  line-height: 1.5;
  opacity: 0.85;
}

/* Register hint */
.auth-modal-hint {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.55;
  margin: 0;
  line-height: 1.5;
}

/* Divider */
.auth-modal-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  margin-top: 20px;
  font-family: inherit;
}

.auth-modal-divider::before,
.auth-modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--muted) 25%, transparent);
}

/* Switch text */
.auth-modal-switch {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 0 0;
  font-family: inherit;
  line-height: 1.5;
}

.auth-modal-switch a {
  color: var(--primary-accent);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.auth-modal-switch a:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* Actions row + Submit button */
.auth-modal-actions {
  display: flex;
  gap: 10px;
  padding-top: 6px;
}

.auth-modal-submit {
  flex: 1;
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  background: var(--accent-gradient);
  color: var(--on-primary);
  box-shadow: 0 4px 20px var(--primary-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-modal-submit:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 28px var(--primary-shadow);
}

.auth-modal-submit:active {
  transform: translateY(0) scale(1);
}

.auth-modal-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Sign In: subtler gradient */
.auth-modal-submit--login {
  background: linear-gradient(135deg, var(--primary-deep), var(--primary-accent));
}

/* Create Account: full accent gradient, slightly taller */
.auth-modal-submit--register {
  background: var(--accent-gradient);
  box-shadow: 0 6px 24px var(--primary-shadow);
  letter-spacing: 0.2px;
}

.auth-modal-submit--register:hover:not(:disabled) {
  box-shadow: 0 8px 32px var(--primary-shadow);
}

/* Legacy auth-btn classes (kept for compatibility elsewhere) */
.auth-btn {
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-btn-primary {
  background: var(--accent-gradient);
  color: var(--on-primary);
  box-shadow: 0 4px 20px var(--primary-shadow);
}

.auth-btn-primary:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 28px var(--primary-shadow);
}

.auth-btn-primary:active {
  transform: translateY(0);
}

.auth-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.auth-btn-secondary {
  background: color-mix(in srgb, var(--surface-2) 70%, rgba(255, 255, 255, 0.03));
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.auth-btn-secondary:hover {
  color: var(--text);
  transform: translateY(-1px);
}

/* Inline divider + switch in settings logged-out card */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--muted) 25%, transparent);
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-family: inherit;
  line-height: 1.5;
}

.auth-switch a {
  color: var(--primary-accent);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.auth-switch a:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* Profile Section in Settings */
.profile-section {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-deep), var(--primary-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--on-primary);
  text-transform: uppercase;
}

.profile-info {
  flex: 1;
}

.profile-username {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px 0;
}

.profile-status {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.profile-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-action-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.profile-action-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.profile-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  white-space: nowrap;
}

.profile-btn-outline {
  background: transparent;
  border: 1px solid var(--surface);
  color: var(--muted);
}

.profile-btn-outline:hover {
  background: var(--surface);
  color: var(--text);
}

.profile-btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.profile-btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.profile-btn-primary {
  background: linear-gradient(180deg, var(--primary-deep), var(--primary-accent));
  color: var(--on-primary);
}

.profile-btn-primary:hover {
  transform: translateY(-1px);
}

/* Login prompt when not logged in */
.profile-login-prompt {
  text-align: center;
  padding: 24px;
}

.profile-login-prompt p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 16px 0;
}

.profile-login-prompt .profile-btn {
  padding: 12px 32px;
}

/* Sync status indicator */
.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 12px;
}

.sync-status-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.sync-status.syncing {
  color: var(--primary-accent);
}

.sync-status.synced {
  color: #22c55e;
}

.sync-status.error {
  color: #ef4444;
}

/* Auth button in header/sidebar */
.auth-header-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.auth-header-btn:hover {
  background: var(--surface);
  transform: translateY(-1px);
}

.auth-header-btn.logged-in {
  background: linear-gradient(180deg, var(--primary-deep), var(--primary-accent));
  color: var(--on-primary);
  border-color: transparent;
}

.auth-header-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Edit fields in profile */
.profile-edit-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  border-radius: 10px;
  margin-bottom: 12px;
}

.profile-edit-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.profile-edit-field input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--surface-2);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.profile-edit-field input:focus {
  outline: none;
  border-color: var(--primary-accent);
}

.profile-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 480px) {
  .auth-modal {
    padding: 24px;
    margin: 12px;
  }
  
  .profile-header {
    flex-direction: column;
    text-align: center;
  }
  
  .profile-action-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .profile-btn {
    width: 100%;
    text-align: center;
  }
}


/* ── Light Mode ── */
.light-scheme .auth-modal {
  background: color-mix(in srgb, var(--surface) 85%, rgba(255, 255, 255, 0.6));
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.03) inset;
}

.light-scheme .auth-field input {
  background: var(--page-bg, #f7f7f8);
  border-color: rgba(0, 0, 0, 0.08);
}


.light-scheme .auth-header-avatar {
  background: rgba(0,0,0,0.05);
}

.light-scheme .auth-error {
  color: #dc2626;
  background: rgba(220,38,38,0.06);
}

.light-scheme .auth-success {
  color: #16a34a;
  background: rgba(22,163,74,0.06);
}

.light-scheme .profile-btn-danger {
  color: #dc2626;
  background: rgba(220,38,38,0.06);
  border-color: rgba(220,38,38,0.15);
}

.light-scheme .profile-btn-danger:hover {
  background: rgba(220,38,38,0.1);
}
