/**
 * Authentication UI Styles for ClueChain
 * Styles for sign-in/sign-out buttons and user profile display
 */

/* Auth Container */
.auth-container {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  position: relative; /* Remove absolute positioning */
}

/* Welcome Screen */
.welcome-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.welcome-content {
  background: white;
  padding: 3rem;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.welcome-content h1 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 2.5rem;
  font-weight: 600;
}

.welcome-content p {
  color: #666;
  margin-bottom: 2rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

.welcome-auth {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-auth p {
  color: #444;
  margin-bottom: 1rem;
  font-weight: 500;
}

#welcome-auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.welcome-auth .sign-in-btn {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.welcome-auth .sign-in-btn:hover {
  transform: scale(1.15);
}

/* Header Layout Improvements */
.game-header .header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  width: 100%;
}

.game-header .right-icon {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Auth container at header level */
.game-header {
  position: relative;
}

.game-header .auth-container {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 10;
}

/* Minimal User Profile */
.user-profile-minimal {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.user-avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.avatar-img-small {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder-small {
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.user-streak-minimal {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: #333;
}

.streak-icon {
  font-size: 14px;
}

.streak-count {
  min-width: 16px;
  text-align: center;
}

/* User Menu */
.user-menu {
  position: relative;
}

.menu-dots {
  background: none;
  border: none;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.menu-dots:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 120px;
  opacity: 0;
  transform: translateY(-10px);
  visibility: hidden;
  transition: all 0.2s ease;
}

.menu-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background-color 0.2s ease;
}

.menu-item:hover {
  background: #f5f5f5;
}

.menu-item:first-child {
  border-radius: 8px 8px 0 0;
}

.menu-item:last-child {
  border-radius: 0 0 8px 8px;
}

/* Guest Mode UI */
.guest-mode {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.guest-label {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.sign-in-btn-small {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sign-in-btn-small:hover {
  background: #f8f9fa;
  border-color: #c6c6c6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.sign-in-btn-small:active {
  background: #f1f3f4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.google-icon-small {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Sign In Button */
.sign-in-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sign-in-btn:hover {
  background: #f8f9fa;
  border-color: #c6c6c6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.sign-in-btn:active {
  background: #f1f3f4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sign-in-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Google Icon */
.google-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* User Profile */
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* User Avatar */
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  background: #4a90e2;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

/* User Info */
.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.user-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #666;
}

.streak-icon {
  font-size: 14px;
}

.streak-count {
  font-weight: 600;
  color: #e65100;
}

/* Sign Out Button */
.sign-out-btn {
  padding: 4px 8px;
  background: #f8f9fa;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 12px;
  color: #5f6368;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sign-out-btn:hover {
  background: #e8eaed;
  border-color: #c6c6c6;
}

.sign-out-btn:active {
  background: #e0e0e0;
}

.sign-out-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
  .game-header {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .game-header .auth-container {
    position: static;
    transform: none;
    margin-top: 2px;
    margin-bottom: 2px;
    order: 1; /* between header-content and any following content */
  }

  .game-header .header-content {
    order: 0;
    width: 100%;
  }

  .auth-container {
    position: static;
    justify-content: center;
  }
  
  .user-profile {
    padding: 6px 10px;
    gap: 8px;
  }
  
  .user-avatar {
    width: 28px;
    height: 28px;
  }
  
  .user-name {
    font-size: 13px;
    max-width: 80px;
  }
  
  .user-streak {
    font-size: 11px;
  }
  
  .sign-in-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .sign-out-btn {
    padding: 3px 6px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .auth-container {
    width: 100%;
    justify-content: center;
  }
  
  .user-profile {
    flex-direction: column;
    text-align: center;
    padding: 8px;
  }
  
  .user-info {
    align-items: center;
  }
  
  .user-name {
    max-width: none;
  }
  
  .sign-in-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Loading States */
.sign-in-btn:disabled,
.sign-out-btn:disabled {
  position: relative;
  color: transparent;
}

.sign-in-btn:disabled::after,
.sign-out-btn:disabled::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #666;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Auth Error Messages */
.auth-error {
  color: #d32f2f;
  font-size: 12px;
  margin-top: 4px;
  text-align: center;
}

/* Auth Success Messages */
.auth-success {
  color: #388e3c;
  font-size: 12px;
  margin-top: 4px;
  text-align: center;
}

/* Streak Animation */
.streak-count {
  animation: streakPulse 2s infinite;
}

@keyframes streakPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* High Streak Special Effects */
.streak-count[data-streak="7"],
.streak-count[data-streak="14"],
.streak-count[data-streak="30"] {
  animation: streakCelebration 1s ease-out;
}

@keyframes streakCelebration {
  0% { transform: scale(1); }
  25% { transform: scale(1.2); }
  50% { transform: scale(1.1); }
  75% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Streak Milestone Indicators */
.streak-milestone {
  position: relative;
}

.streak-milestone::after {
  content: "🏆";
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: 10px;
  opacity: 0.8;
}

/* Accessibility */
.sign-in-btn:focus,
.sign-out-btn:focus {
  outline: 2px solid #4285f4;
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .user-profile {
    border: 2px solid #000;
  }
  
  .sign-in-btn,
  .sign-out-btn {
    border: 2px solid #000;
  }
}

/* Auth Gate Modal */
.auth-gate-modal-content {
  max-width: 400px;
  width: 90%;
  border-radius: 12px;
  overflow: hidden;
}

.auth-gate-header {
  padding: 1.5rem 1.5rem 0.75rem;
  border-bottom: none;
  justify-content: center;
}

.auth-gate-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  text-align: center;
  margin: 0;
}

.auth-gate-body {
  padding: 0.75rem 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.auth-gate-subtitle {
  color: #666;
  font-size: 0.95rem;
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

.auth-gate-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.auth-gate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.auth-gate-google {
  background: #ffffff;
  border: 1px solid #dadce0;
  color: #3c4043;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-gate-google:hover {
  background: #f8f9fa;
  border-color: #c6c6c6;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.auth-gate-google:active {
  background: #f1f3f4;
}

.auth-gate-guest {
  background: #f1f3f4;
  color: #5f6368;
}

.auth-gate-guest:hover {
  background: #e8eaed;
  color: #3c4043;
}

.auth-gate-guest:active {
  background: #dadce0;
}

/* Dark Mode Support (future enhancement) */
@media (prefers-color-scheme: dark) {
  .user-profile {
    background: #2d2d2d;
    border-color: #555;
    color: #fff;
  }
  
  .user-name {
    color: #fff;
  }
  
  .user-streak {
    color: #ccc;
  }
  
  .sign-in-btn {
    background: #2d2d2d;
    border-color: #555;
    color: #fff;
  }
  
  .sign-out-btn {
    background: #3d3d3d;
    border-color: #555;
    color: #ccc;
  }
}