/* FitCoin MVP - Authentication Styles */

/* Authentication Modal */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-lg);
  backdrop-filter: blur(4px);
}

.auth-modal-content {
  background: var(--color-background);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: authModalSlideIn 0.3s ease-out;
}

@keyframes authModalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Auth Header */
.auth-header {
  text-align: center;
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  position: relative;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  color: white;
}

.auth-logo {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  filter: brightness(0) invert(1);
}

.auth-header h2 {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
}

.auth-header p {
  margin: 0;
  opacity: 0.9;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.auth-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: var(--radius-full);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.auth-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Auth Form */
.auth-form {
  padding: var(--space-xl);
}

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

.form-group label {
  display: block;
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-xs);
}

.form-group input {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background: var(--color-background);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(6, 150, 175, 0.1);
}

.form-group input::placeholder {
  color: var(--color-text-tertiary);
}

/* Form Options */
.form-options {
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.checkbox-wrapper input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  width: 0;
  height: 0;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-right: var(--space-sm);
  position: relative;
  transition: all 0.2s ease;
}

.checkbox-wrapper:hover .checkmark {
  border-color: var(--color-primary);
}

.checkbox-wrapper input:checked ~ .checkmark {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox-wrapper input:checked ~ .checkmark::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: 2px solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-wrapper a {
  color: var(--color-primary);
  text-decoration: none;
}

.checkbox-wrapper a:hover {
  text-decoration: underline;
}

/* Auth Submit Button */
.auth-submit {
  width: 100%;
  margin-bottom: var(--space-lg);
  height: 48px;
  position: relative;
  overflow: hidden;
}

.auth-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Auth Divider */
.auth-divider {
  text-align: center;
  margin: var(--space-lg) 0;
  position: relative;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-sm);
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--color-border);
  z-index: -1;
}

.auth-divider span {
  background: var(--color-background);
  padding: 0 var(--space-md);
}

/* Auth Links */
.auth-links {
  text-align: center;
  margin-top: var(--space-lg);
}

.auth-links a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

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

/* Auth Error */
.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-error);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin: var(--space-md) var(--space-xl) 0;
  font-size: var(--font-size-sm);
  display: none;
  animation: errorSlideIn 0.3s ease-out;
}

@keyframes errorSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header Authentication */
.header-auth {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-right: var(--space-md);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  position: relative;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  transition: background-color 0.2s ease;
}

.user-info:hover {
  background: rgba(6, 150, 175, 0.1);
}

.user-avatar {
  font-size: var(--font-size-lg);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  color: white;
}

.user-name {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

.user-menu-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}

.user-menu-btn:hover {
  color: var(--color-text-primary);
}

/* User Menu Dropdown */
.user-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 180px;
  z-index: var(--z-dropdown);
  animation: dropdownSlideIn 0.2s ease-out;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  color: var(--color-text-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: background-color 0.2s ease;
}

.user-menu a:hover {
  background: var(--color-surface);
}

.user-menu a:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.user-menu a:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  color: var(--color-error);
}

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

/* Button Variants */
.btn-ghost {
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-surface);
}

.btn-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  height: auto;
}

/* Dark theme adjustments */
[data-theme="dark"] .auth-modal-content {
  border: 1px solid var(--color-border);
}

[data-theme="dark"] .auth-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .user-info:hover {
  background: rgba(6, 150, 175, 0.15);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .auth-modal {
    padding: var(--space-md);
  }

  .auth-modal-content {
    max-width: 100%;
  }

  .auth-header {
    padding: var(--space-lg);
  }

  .auth-form {
    padding: var(--space-lg);
  }

  .header-auth {
    gap: var(--space-xs);
  }

  .user-name {
    display: none;
  }

  .btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
  }

  .user-menu {
    right: -8px;
    min-width: 160px;
  }
}

/* Focus states for accessibility */
.auth-close:focus,
.form-group input:focus,
.checkbox-wrapper:focus-within .checkmark,
.user-menu-btn:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Welcome screen user info */
.welcome-user-info {
  text-align: center;
  margin-bottom: var(--space-lg);
  padding: var(--space-lg);
  background: linear-gradient(135deg, rgba(6, 150, 175, 0.1), rgba(16, 185, 129, 0.1));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(6, 150, 175, 0.2);
}

.welcome-user-info h3 {
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  margin: 0 0 var(--space-xs) 0;
}

.welcome-user-info p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
  margin: 0;
}

/* Teams System Styles */
.team-info {
  display: flex;
  align-items: center;
  margin-right: var(--space-md);
}

.team-badge {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.team-badge:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.team-badge i {
  font-size: var(--font-size-sm);
}

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

/* Team Modal */
.team-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-lg);
  backdrop-filter: blur(4px);
}

.team-modal-content {
  background: var(--color-background);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: teamModalSlideIn 0.3s ease-out;
}

@keyframes teamModalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.team-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.team-title h2 {
  color: var(--color-text-primary);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  margin: 0 0 var(--space-xs) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.company-name {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin: 0;
}

.team-close {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.team-close:hover {
  background: var(--color-error);
  color: white;
  border-color: var(--color-error);
}

/* Team Stats */
.team-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-md);
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.stat-card {
  text-align: center;
  padding: var(--space-lg);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.stat-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

/* Active Challenge */
.active-challenge {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.active-challenge h3 {
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-md) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.challenge-card {
  background: linear-gradient(135deg, rgba(6, 150, 175, 0.1), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(6, 150, 175, 0.2);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.challenge-info h4 {
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-xs) 0;
}

.challenge-info p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin: 0;
}

.progress-circle {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: conic-gradient(var(--color-primary) 65%, var(--color-border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.progress-circle::before {
  content: '';
  position: absolute;
  width: 45px;
  height: 45px;
  background: var(--color-background);
  border-radius: var(--radius-full);
}

.progress-circle span {
  position: relative;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
}

/* Team Actions */
.team-actions {
  padding: var(--space-xl);
  display: flex;
  gap: var(--space-md);
}

.team-actions .btn {
  flex: 1;
}

/* Join Team Options */
.join-team-options {
  padding: var(--space-xl);
}

.join-team-options h3 {
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-md) 0;
}

.available-teams {
  margin-bottom: var(--space-xl);
}

.teams-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.team-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease;
}

.team-option:hover {
  border-color: var(--color-primary);
}

.team-option .team-info h4 {
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-xs) 0;
}

.team-option .team-info p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin: 0;
}

.create-team-section {
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.create-team-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Dark theme adjustments */
[data-theme="dark"] .team-badge {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme="dark"] .team-modal-content {
  border: 1px solid var(--color-border);
}

[data-theme="dark"] .challenge-card {
  background: linear-gradient(135deg, rgba(6, 150, 175, 0.15), rgba(16, 185, 129, 0.15));
  border-color: rgba(6, 150, 175, 0.3);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .team-modal {
    padding: var(--space-md);
  }

  .team-modal-content {
    max-width: 100%;
  }

  .team-name {
    display: none;
  }

  .team-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    padding: var(--space-md);
  }

  .stat-card {
    padding: var(--space-md);
  }

  .team-actions {
    flex-direction: column;
  }

  .challenge-card {
    flex-direction: column;
    text-align: center;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .auth-header {
    background: var(--color-primary);
  }

  .form-group input {
    border-width: 2px;
  }

  .checkmark {
    border-width: 2px;
  }

  .team-badge,
  .stat-card,
  .challenge-card,
  .team-option {
    border-width: 2px;
  }
}

/* Settings Modal Styles */
.settings-content {
  padding: var(--space-lg);
  max-height: 60vh;
  overflow-y: auto;
}

.settings-section {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section h3 {
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-md) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.setting-group label {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

/* Theme Options */
.theme-options {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  min-width: 80px;
}

.theme-btn:hover {
  border-color: var(--color-primary);
  background: rgba(6, 150, 175, 0.1);
}

.theme-btn.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: white;
}

.theme-btn i {
  font-size: var(--font-size-lg);
}

/* Toggle Switch */
.setting-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.setting-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.3s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: var(--radius-full);
  top: 2px;
  left: 2px;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.setting-toggle input:checked + .toggle-slider {
  background: var(--color-primary);
}

.setting-toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Account Info */
.account-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.account-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
}

.account-detail label {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.account-detail span {
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.setting-group small {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  margin-top: -var(--space-xs);
}

/* Setting Description */
.setting-description {
  margin-bottom: var(--space-md);
}

.setting-description p {
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space-xs) 0;
}

.setting-description small {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
}

/* Warning Button */
.btn-warning {
  background: #f59e0b;
  color: white;
  border: 1px solid #f59e0b;
}

.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
}

/* Avatar Image */
.avatar-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-block;
}

/* Settings Footer */
.settings-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
}

/* Dark theme adjustments for settings */
[data-theme="dark"] .theme-btn {
  background: var(--color-background);
  border-color: var(--color-border);
}

[data-theme="dark"] .theme-btn:hover {
  background: rgba(6, 150, 175, 0.15);
}

[data-theme="dark"] .toggle-slider::before {
  background: var(--color-surface);
}

/* Mobile adjustments for settings */
@media (max-width: 640px) {
  .settings-content {
    padding: var(--space-md);
  }

  .theme-options {
    justify-content: center;
  }

  .theme-btn {
    min-width: 70px;
    padding: var(--space-sm);
  }

  .account-detail {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
}