/* =============================================
   Code Playground — Auth Styles (auth.css)
   Add this file to your project and link it in editor.html
   ============================================= */

/* --- Auth Overlay & Modal --- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.auth-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.auth-modal {
  background: #1c2128;
  border: 1px solid #333c46;
  border-radius: 16px;
  width: 400px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: authSlideUp 0.25s ease-out;
}

@keyframes authSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: #6e7681;
  font-size: 22px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.auth-close:hover {
  background: #2d333b;
  color: #e6edf3;
}

/* Header */
.auth-header {
  text-align: center;
  padding: 32px 32px 0;
}
.auth-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: #58a6ff;
  margin-bottom: 12px;
}
.auth-title {
  font-size: 20px;
  font-weight: 600;
  color: #e6edf3;
  margin: 0 0 6px;
}
.auth-subtitle {
  font-size: 13px;
  color: #6e7681;
  margin: 0;
}

/* Body */
.auth-body {
  padding: 24px 32px 32px;
}

/* OAuth */
.auth-oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #333c46;
  border-radius: 10px;
  background: #2d333b;
  color: #e6edf3;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 10px;
  font-family: 'DM Sans', sans-serif;
}
.auth-oauth-btn:hover {
  background: #373e47;
  border-color: #444c56;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: #484f58;
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #2d333b;
}

/* Form */
.auth-field {
  margin-bottom: 14px;
}
.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #adbac7;
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #333c46;
  border-radius: 10px;
  background: #0d1117;
  color: #e6edf3;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.auth-field input:focus {
  border-color: #58a6ff;
}
.auth-field input::placeholder {
  color: #484f58;
}

.auth-error {
  font-size: 13px;
  color: #f97583;
  min-height: 18px;
  margin-bottom: 8px;
}

.auth-submit-btn {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: 10px;
  background: #238636;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'DM Sans', sans-serif;
}
.auth-submit-btn:hover {
  background: #2ea043;
}
.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: #6e7681;
  margin-top: 18px;
}
.auth-switch a {
  color: #58a6ff;
  text-decoration: none;
  font-weight: 500;
}
.auth-switch a:hover {
  text-decoration: underline;
}


/* --- User Menu (Header) --- */
.user-menu {
  position: relative;
  margin-left: 6px;
  z-index: 9999;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  color: #e6edf3;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s, border-color 0.15s;
}
.user-menu-btn:hover {
  background: #2d333b;
  border-color: #333c46;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #58a6ff;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.plan-badge.plan-pro {
  background: #1f6feb;
  color: #fff;
}
.plan-badge.plan-free {
  background: #30363d;
  color: #8b949e;
}

/* Dropdown */
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #1c2128;
  border: 1px solid #333c46;
  border-radius: 12px;
  min-width: 220px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 1000;
}
.user-dropdown.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.user-dropdown-header {
  padding: 14px 16px 10px;
}
.user-dropdown-email {
  font-size: 13px;
  color: #e6edf3;
  font-weight: 500;
  word-break: break-all;
}
.user-dropdown-plan {
  font-size: 12px;
  color: #6e7681;
  margin-top: 2px;
}

.user-dropdown-divider {
  height: 1px;
  background: #2d333b;
  margin: 0 12px;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: #adbac7;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s, color 0.15s;
}
.user-dropdown-item:hover {
  background: #2d333b;
  color: #e6edf3;
}
.user-dropdown-item:last-child {
  border-radius: 0 0 12px 12px;
}

.upgrade-item {
  color: #f0c000;
}
.upgrade-item:hover {
  color: #ffd43b;
}

/* Sign In button in header — self-contained (works without style.css) */
.auth-header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  border: 1px solid #333c46;
  border-radius: 8px;
  background: transparent;
  color: #b8c5d6;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  margin-left: 6px;
}
.auth-header-btn:hover {
  border-color: #5ce0d0;
  color: #5ce0d0;
  background: rgba(92, 224, 208, 0.06);
}

/* --- Toast --- */
.auth-toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #2d333b;
  color: #e6edf3;
  border: 1px solid #444c56;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.auth-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* --- Light theme overrides --- */
body.light-theme .auth-modal {
  background: #ffffff;
  border-color: #d0d7de;
}
body.light-theme .auth-close { color: #8c959f; }
body.light-theme .auth-close:hover { background: #f0f2f4; color: #24292f; }
body.light-theme .auth-title { color: #24292f; }
body.light-theme .auth-subtitle { color: #656d76; }
body.light-theme .auth-oauth-btn { background: #f6f8fa; border-color: #d0d7de; color: #24292f; }
body.light-theme .auth-oauth-btn:hover { background: #eaeef2; }
body.light-theme .auth-divider { color: #b1bac4; }
body.light-theme .auth-divider::before,
body.light-theme .auth-divider::after { background: #d8dee4; }
body.light-theme .auth-field label { color: #57606a; }
body.light-theme .auth-field input { background: #f6f8fa; border-color: #d0d7de; color: #24292f; }
body.light-theme .auth-field input:focus { border-color: #0969da; }
body.light-theme .auth-field input::placeholder { color: #8c959f; }
body.light-theme .auth-switch { color: #656d76; }
body.light-theme .auth-switch a { color: #0969da; }
body.light-theme .user-menu-btn { color: #24292f; }
body.light-theme .user-menu-btn:hover { background: #f0f2f4; border-color: #d0d7de; }
body.light-theme .user-dropdown { background: #fff; border-color: #d0d7de; }
body.light-theme .user-dropdown-email { color: #24292f; }
body.light-theme .user-dropdown-divider { background: #d8dee4; }
body.light-theme .user-dropdown-item { color: #57606a; }
body.light-theme .user-dropdown-item:hover { background: #f6f8fa; color: #24292f; }
body.light-theme .auth-toast { background: #fff; color: #24292f; border-color: #d0d7de; }

/* --- Mobile --- */
@media (max-width: 768px) {
  .auth-modal {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
  }
  .auth-overlay {
    align-items: flex-end;
  }
  .user-name { display: none; }
  .user-menu-btn { padding: 4px; }
}

/* Nav-based pages (non-editor): auth in pg-nav-links */
.pg-nav-links .auth-header-btn {
  margin-left: 6px;
}
.pg-nav-links .user-menu {
  margin-left: 6px;
}
@media (max-width: 680px) {
  .pg-nav-links .auth-header-btn {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
  .pg-nav-links .user-menu {
    margin-left: 0;
    width: 100%;
  }
  .pg-nav-links .user-menu-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Nav upgrade button */
.nav-upgrade-btn {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #e07b6b, #c4645a);
  padding: 4px 12px;
  border-radius: 6px;
  text-decoration: none;
  margin-left: 6px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(224, 123, 107, 0.3);
}
.nav-upgrade-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(224, 123, 107, 0.4);
  color: #fff;
}
