/**
 * Profile Customization Styles
 * Styles for Edit Profile modal and button
 */

/* =================================================================
   Profile Modal
   ================================================================= */

#profileModal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in var(--animation-fast) ease-out;
}

#profileModal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.profile-modal-content {
  background: var(--theme-bg-secondary);
  padding: var(--space-6);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: modal-slide-in var(--animation-normal) ease-out;
}

@keyframes modal-slide-in {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.profile-modal-content h2 {
  color: var(--theme-text-primary);
  margin-bottom: var(--space-5);
  text-align: center;
  font-size: var(--font-size-2xl);
}

/* =================================================================
   Form Fields
   ================================================================= */

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

.profile-form-group label {
  display: block;
  color: var(--theme-text-primary);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.profile-form-group input[type="text"] {
  width: 100%;
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-base);
  color: var(--theme-text-primary);
  font-size: 16px;
  box-sizing: border-box;
  transition: border-color var(--animation-fast);
}

.profile-form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px rgba(191, 9, 47, 0.2);
}

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

.profile-error-message {
  color: var(--color-danger);
  font-size: 14px;
  margin-top: var(--space-2);
  display: none;
}

.profile-error-message.show {
  display: block;
}

/* =================================================================
   Photo Upload Section
   ================================================================= */

.profile-photo-section {
  text-align: center;
  margin-bottom: var(--space-5);
}

.profile-photo-preview {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  margin: 0 auto var(--space-4);
  object-fit: cover;
  border: 3px solid var(--theme-border);
  display: block;
}

.profile-photo-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

.profile-photo-btn {
  padding: var(--space-2) var(--space-4);
  background: var(--theme-bg-tertiary);
  color: var(--theme-text-primary);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-base);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--animation-fast);
}

.profile-photo-btn:hover:not(:disabled) {
  background: var(--theme-text-primary);
  color: var(--theme-bg-primary);
  transform: translateY(-1px);
}

.profile-photo-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =================================================================
   Camera Preview
   ================================================================= */

.camera-preview-container {
  display: none;
  margin-top: var(--space-4);
}

.camera-preview-container.show {
  display: block;
}

#cameraPreview {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius-base);
  margin: 0 auto;
  display: block;
  border: 1px solid var(--theme-border);
}

.camera-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-3);
}

/* =================================================================
   Avatar Gallery
   ================================================================= */

.avatar-gallery-toggle-btn {
  margin-top: var(--space-4);
  width: 100%;
  padding: var(--space-3);
  background: var(--theme-bg-tertiary);
  color: var(--theme-text-primary);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-base);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--animation-fast);
}

.avatar-gallery-toggle-btn:hover:not(:disabled),
.avatar-gallery-toggle-btn:focus-visible {
  background: var(--theme-text-primary);
  color: var(--theme-bg-primary);
  transform: translateY(-1px);
  outline: none;
}

.avatar-gallery-toggle-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.avatar-gallery-section {
  display: none;
  margin-top: var(--space-4);
  animation: gallery-slide-down var(--animation-normal) ease-out;
}

.avatar-gallery-section.show {
  display: block;
}

.avatar-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
  max-height: 240px;
  overflow-y: auto;
  padding-right: var(--space-1);
}

.avatar-option {
  position: relative;
  padding-top: 100%; /* Square ratio */
  border: 2px solid transparent;
  border-radius: var(--radius-base);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform var(--animation-fast), border-color var(--animation-fast), box-shadow var(--animation-fast);
}

.avatar-option:hover,
.avatar-option:focus-visible {
  transform: translateY(-2px);
  border-color: var(--color-brand-primary);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  outline: none;
}

.avatar-option.selected {
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px rgba(191, 9, 47, 0.25);
  background: rgba(191, 9, 47, 0.15);
}

.avatar-option img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

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

/* =================================================================
   Modal Actions
   ================================================================= */

.profile-modal-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.profile-modal-actions button {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-radius: var(--radius-base);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--animation-fast);
}

.profile-save-btn {
  background: var(--color-brand-primary);
  color: white;
}

.profile-save-btn:hover:not(:disabled) {
  background: var(--color-brand-primary-hover);
  transform: translateY(-1px);
}

.profile-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-cancel-btn {
  background: var(--theme-bg-tertiary);
  color: var(--theme-text-primary);
}

.profile-cancel-btn:hover {
  background: var(--theme-text-primary);
  color: var(--theme-bg-primary);
  transform: translateY(-1px);
}

/* =================================================================
   Hidden File Input
   ================================================================= */

#photoFileInput {
  display: none;
}

/* =================================================================
   Mobile Responsive
   ================================================================= */

@media (max-width: 600px) {
  .profile-modal-content {
    width: 95%;
    padding: var(--space-5);
  }

  .profile-photo-actions {
    flex-direction: column;
  }

  .profile-photo-btn {
    width: 100%;
  }

  .profile-modal-actions {
    flex-direction: column;
  }

  .avatar-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
