/* ============================================
   SafeGameHub - Authentication Styles
   All classes use sgh- prefix to avoid collisions
   ============================================ */

/* --- Auth Container (far right of header) --- */
.sgh-auth-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  margin-left: auto;
}

/* --- Nav Auth Buttons (Logged Out) --- */
.sgh-auth-btn {
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-primary);
  white-space: nowrap;
  transition: all var(--transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border: none;
  line-height: 1.4;
}

.sgh-signin-btn {
  color: var(--gray-dark);
  background: transparent;
}

.sgh-signin-btn:hover {
  background: var(--gray-lightest);
  color: var(--black);
}

.sgh-signup-btn {
  background: var(--accent);
  color: white;
}

.sgh-signup-btn:hover {
  background: var(--accent-dark);
  box-shadow: var(--shadow-md);
}

/* --- User Avatar Menu (Logged In) --- */
.sgh-user-menu {
  position: relative;
  flex-shrink: 0;
}

.sgh-avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--white);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  overflow: hidden;
}

.sgh-avatar-btn:hover {
  opacity: 0.8;
}

.sgh-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.sgh-avatar-initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  color: white;
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

/* --- Dropdown Menu --- */
.sgh-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  padding: var(--space-sm) 0;
  display: none;
  z-index: 1001;
}

.sgh-user-dropdown.active {
  display: block;
}

.sgh-dropdown-header {
  padding: var(--space-md) var(--space-lg);
}

.sgh-dropdown-header strong {
  display: block;
  font-family: var(--font-primary);
  font-size: 15px;
  font-weight: 600;
  color: var(--black);
}

.sgh-dropdown-header span {
  display: block;
  font-size: 13px;
  color: var(--gray);
  margin-top: 2px;
}

.sgh-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-xs) 0;
}

.sgh-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-dark);
  text-decoration: none;
  transition: background var(--transition-fast);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.sgh-dropdown-item:hover {
  background: var(--gray-lightest);
  color: var(--black);
}

.sgh-dropdown-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sgh-dropdown-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Auth Form Pages (login.html, signup.html) --- */
.sgh-auth-page {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  background: var(--bg-secondary);
}

.sgh-auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2xl);
}

.sgh-auth-card h1 {
  font-family: var(--font-primary);
  font-size: 28px;
  font-weight: 700;
  color: var(--black);
  margin-bottom: var(--space-sm);
}

.sgh-auth-subtitle {
  font-size: 15px;
  color: var(--gray);
  margin-bottom: var(--space-xl);
}

.sgh-form-group {
  margin-bottom: var(--space-lg);
}

.sgh-form-group label {
  display: block;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: var(--space-sm);
}

.sgh-form-group input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-primary);
  font-size: 15px;
  color: var(--black);
  transition: all var(--transition-fast);
  background: var(--white);
  box-sizing: border-box;
}

.sgh-form-group input:focus {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 1px var(--black);
}

.sgh-form-group input.sgh-input-error {
  border-color: var(--danger);
}

.sgh-form-group input.sgh-input-error:focus {
  box-shadow: 0 0 0 1px var(--danger);
}

.sgh-form-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: var(--space-xs);
  display: none;
}

.sgh-form-error.visible {
  display: block;
}

.sgh-auth-submit {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: var(--space-sm);
}

.sgh-auth-submit:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-lg);
}

.sgh-auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.sgh-auth-footer {
  text-align: center;
  margin-top: var(--space-xl);
  font-size: 14px;
  color: var(--gray);
}

.sgh-auth-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.sgh-auth-footer a:hover {
  text-decoration: underline;
}

.sgh-auth-alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 14px;
  margin-bottom: var(--space-lg);
  display: none;
}

.sgh-auth-alert.sgh-alert-error {
  background: var(--danger-light);
  color: var(--danger);
  display: block;
}

.sgh-auth-alert.sgh-alert-success {
  background: var(--success-light);
  color: var(--success);
  display: block;
}

/* --- Dashboard --- */
.sgh-dashboard {
  padding: var(--space-2xl) 0 var(--space-3xl);
  min-height: calc(100vh - 80px - 300px);
  background: var(--bg-secondary);
}

.sgh-dashboard-header {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.sgh-dashboard-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.sgh-dashboard-avatar-initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  color: white;
  font-family: var(--font-primary);
  font-size: 32px;
  font-weight: 700;
}

.sgh-dashboard-info h1 {
  font-family: var(--font-primary);
  font-size: 24px;
  font-weight: 700;
  color: var(--black);
  margin: 0;
}

.sgh-dashboard-info p {
  font-size: 15px;
  color: var(--gray);
  margin-top: 4px;
}

.sgh-dashboard-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  margin-top: 8px;
}

.sgh-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.sgh-dashboard-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.sgh-dashboard-card h3 {
  font-family: var(--font-primary);
  font-size: 18px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: var(--space-md);
  margin-top: 0;
}

.sgh-dashboard-card p {
  font-size: 14px;
  color: var(--gray);
  line-height: 1.6;
}

.sgh-dashboard-card-full {
  grid-column: 1 / -1;
}

.sgh-account-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.sgh-account-row:last-child {
  border-bottom: none;
}

.sgh-account-label {
  color: var(--gray);
  font-weight: 500;
}

.sgh-account-value {
  color: var(--black);
  font-weight: 600;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  /* Auth container: hidden by default on mobile, shown when nav is active */
  .sgh-auth-container {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    z-index: 999;
    gap: var(--space-sm);
  }

  /* Show auth container when mobile menu is open */
  .nav-menu.active ~ .sgh-auth-container {
    display: flex;
  }

  .sgh-auth-btn {
    flex: 1;
    padding: 14px var(--space-md);
    font-size: 16px;
    justify-content: center;
  }

  .sgh-signin-btn {
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
  }

  .sgh-signup-btn {
    border-radius: var(--radius-full);
  }

  /* Avatar on mobile: show in fixed bar */
  .sgh-user-menu {
    width: 100%;
  }

  .sgh-avatar-btn {
    width: 100%;
    height: auto;
    border-radius: var(--radius-full);
    padding: 10px var(--space-md);
    flex-direction: row;
    gap: var(--space-sm);
    border: 1px solid var(--border);
  }

  .sgh-avatar-btn .sgh-avatar-initial {
    width: 32px;
    height: 32px;
    font-size: 14px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .sgh-user-dropdown {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    padding-bottom: var(--space-xl);
    z-index: 10002;
    display: block;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.3s ease-out, visibility 0.3s ease-out;
  }

  .sgh-user-dropdown.active {
    transform: translateY(0);
    visibility: visible;
  }

  .sgh-user-dropdown::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--gray-light);
    border-radius: 2px;
  }

  .sgh-dropdown-header {
    padding-top: var(--space-xl);
  }

  .sgh-dropdown-item {
    padding: 14px var(--space-lg);
    font-size: 16px;
  }

  .sgh-auth-page {
    padding: var(--space-xl) var(--space-md);
    align-items: flex-start;
    padding-top: var(--space-2xl);
  }

  .sgh-auth-card {
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
  }

  .sgh-auth-card h1 {
    font-size: 24px;
  }

  /* Dashboard mobile styles */
  .sgh-dashboard {
    padding: 12px 8px;
  }

  .sgh-dashboard-header {
    flex-direction: column;
    text-align: center;
  }

  .sgh-dashboard-grid {
    display: block;
  }

  .sgh-dashboard-card {
    margin-bottom: 16px;
  }

  .sgh-dashboard-card-full {
    grid-column: auto;
  }

  .sgh-saved-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .sgh-saved-tabs::-webkit-scrollbar {
    display: none;
  }

  .sgh-saved-tab {
    flex-shrink: 0;
  }
}

/* --- Save Button (matches vote button style) --- */
.sgh-save-btn {
  background: none;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sgh-save-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.sgh-save-btn:active {
  transform: scale(1.15);
}

.sgh-save-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: all 0.15s ease;
}

.sgh-save-btn span {
  display: none;
}

.sgh-save-btn.saved {
  color: var(--accent);
}

.sgh-save-btn.saved svg {
  fill: var(--accent);
}

.sgh-save-btn.saved:hover {
  background: var(--accent-light);
}

.sgh-save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Game Detail Page Save Button (matches share btn-icon) --- */
.game-detail-actions .sgh-save-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.game-detail-actions .sgh-save-btn:hover {
  color: var(--accent-dark);
  background: transparent;
}

.game-detail-actions .sgh-save-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.game-detail-actions .sgh-save-btn span {
  display: none;
}

.game-detail-actions .sgh-save-btn.saved {
  color: var(--accent);
}

.game-detail-actions .sgh-save-btn.saved svg {
  fill: var(--accent);
}

/* --- Question Header Save/Share Buttons --- */
.question-header-btn {
  width: auto !important;
  height: auto !important;
  border-radius: 0 !important;
  background: none !important;
}

.question-header-btn span {
  display: inline !important;
}

.question-header-btn:hover {
  color: white !important;
  background: none !important;
  opacity: 1;
}

.question-header-btn.saved {
  color: white !important;
}

.question-header-btn.saved svg {
  fill: white !important;
  stroke: white !important;
}

/* --- Share Button in Answer Header (matches vote button style) --- */
.answer-header .sgh-share-btn {
  background: none;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  cursor: pointer;
  color: var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.answer-header .sgh-share-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.answer-header .sgh-share-btn:active {
  transform: scale(1.15);
}

.answer-header .sgh-share-btn svg {
  width: 16px;
  height: 16px;
}

/* --- Share Button Shared State --- */
.sgh-share-btn.shared,
.btn-icon[aria-label="Share"].shared {
  color: var(--accent);
}

.sgh-share-btn.shared svg,
.btn-icon[aria-label="Share"].shared svg {
  stroke: var(--accent);
}

.sgh-share-btn.shared svg circle,
.btn-icon[aria-label="Share"].shared svg circle {
  fill: var(--accent);
}

.sgh-share-btn.shared span {
  display: inline;
}

/* Question header share button shared state */
.question-header-btn.sgh-share-btn.shared {
  color: white !important;
}

.question-header-btn.sgh-share-btn.shared svg {
  stroke: white !important;
}

.question-header-btn.sgh-share-btn.shared svg circle {
  fill: white !important;
}

/* --- Article Header Save/Share Buttons (same as question) --- */
.article-header-btn {
  width: auto !important;
  height: auto !important;
  border-radius: 0 !important;
  background: none !important;
}

.article-header-btn span {
  display: inline !important;
}

.article-header-btn:hover {
  color: white !important;
  background: none !important;
  opacity: 1;
}

.article-header-btn.saved {
  color: white !important;
}

.article-header-btn.saved svg {
  fill: white !important;
  stroke: white !important;
}

/* Article header share button shared state */
.article-header-btn.sgh-share-btn.shared {
  color: white !important;
}

.article-header-btn.sgh-share-btn.shared svg {
  stroke: white !important;
}

.article-header-btn.sgh-share-btn.shared svg circle {
  fill: white !important;
}

/* --- Card Save Button (for listing pages) --- */
.sgh-card-save {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 10;
  backdrop-filter: blur(4px);
}

.sgh-card-save:hover {
  background: white;
  transform: scale(1.1);
}

.sgh-card-save svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  transition: all var(--transition-fast);
}

.sgh-card-save.saved svg {
  fill: var(--accent);
}

/* --- Activity List --- */
.sgh-activity-list {
  list-style: none;
  padding: 0;
  padding-right: 12px;
  margin: 0;
  max-height: 350px;
  overflow-y: auto;
}

.sgh-activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

.sgh-activity-item:last-child {
  border-bottom: none;
}

.sgh-activity-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sgh-activity-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sgh-activity-text {
  font-size: 14px;
  color: var(--black);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sgh-activity-text a {
  color: var(--accent);
  text-decoration: none;
}

.sgh-activity-text a:hover {
  text-decoration: underline;
}

.sgh-activity-time {
  font-size: 12px;
  color: var(--gray);
  margin-top: 2px;
}

/* --- Saved Items Grid --- */
.sgh-saved-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-sm);
}

.sgh-saved-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.sgh-saved-tab:hover {
  color: var(--black);
  background: var(--gray-lightest);
}

.sgh-saved-tab.active {
  color: var(--accent);
  background: var(--accent-light);
}

.sgh-saved-tab .count {
  margin-left: 4px;
  font-size: 12px;
  opacity: 0.7;
}

.sgh-saved-list {
  list-style: none;
  padding: 0;
  padding-right: 12px;
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
}

/* Custom scrollbar for lists */
.sgh-saved-list::-webkit-scrollbar,
.sgh-activity-list::-webkit-scrollbar {
  width: 6px;
}

.sgh-saved-list::-webkit-scrollbar-track,
.sgh-activity-list::-webkit-scrollbar-track {
  background: var(--gray-lightest);
  border-radius: 3px;
}

.sgh-saved-list::-webkit-scrollbar-thumb,
.sgh-activity-list::-webkit-scrollbar-thumb {
  background: var(--gray-light);
  border-radius: 3px;
}

.sgh-saved-list::-webkit-scrollbar-thumb:hover,
.sgh-activity-list::-webkit-scrollbar-thumb:hover {
  background: var(--gray);
}

.sgh-saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  transition: all var(--transition-fast);
}

.sgh-saved-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.sgh-saved-item-info {
  flex: 1;
  min-width: 0;
}

.sgh-saved-item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--black);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sgh-saved-item-title a {
  color: inherit;
  text-decoration: none;
}

.sgh-saved-item-title a:hover {
  color: var(--accent);
}

.sgh-saved-item-meta {
  font-size: 12px;
  color: var(--gray);
  margin-top: 2px;
}

.sgh-saved-item-remove {
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sgh-saved-item-remove:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.sgh-saved-item-remove svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.sgh-shared-icon {
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sgh-empty-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--gray);
}

.sgh-empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--gray-light);
  stroke-width: 1.5;
  fill: none;
  margin-bottom: var(--space-md);
}

/* Dropdown overlay for mobile bottom sheet */
.sgh-dropdown-overlay {
  display: none;
}

@media (max-width: 768px) {
  .sgh-dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
    display: block;
  }

  .sgh-dropdown-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* User dropdown slide up animation for mobile */
@keyframes userDropdownSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
