* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Background Gallery Styles - Only visible during login */
.background-gallery {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: #1a1a1a;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  padding: 15px;
  overflow: auto;
  animation: fadeIn 0.5s ease-in;
}

.background-gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  opacity: 0.3; /* Restored to 30% opacity for subtle blanket effect */
  border-radius: 8px;
  filter: grayscale(50%); /* Increased grayscale for more muted colors */
  transition: all 0.3s ease;
}

/* Subtle animation for the background images */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Responsive grid adjustments */
@media (max-width: 1200px) {
  .background-gallery {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .background-gallery img {
    height: 150px;
  }
}

@media (max-width: 768px) {
  .background-gallery {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    padding: 10px;
  }

  .background-gallery img {
    height: 100px;
  }
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Authentication Styles */
.auth-modal {
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
}

.auth-modal {
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
}

.auth-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 40px;
  border-radius: 20px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-header h2 {
  color: #333;
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.auth-header p {
  color: #666;
  font-size: 1rem;
}

.auth-tabs {
  display: flex;
  margin-bottom: 30px;
  border-bottom: 2px solid #f0f0f0;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
}

.auth-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-input {
  width: 100%;
  padding: 15px;
  border: 2px solid #e1e5e9;
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.3s ease;
  margin-bottom: 5px;
}

.auth-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
}

.auth-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

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

.auth-divider {
  text-align: center;
  margin: 25px 0;
  position: relative;
  color: #666;
}

.auth-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e1e5e9;
}

.auth-divider span {
  background: white;
  padding: 0 15px;
  position: relative;
  z-index: 1;
}

.auth-error {
  background: #ff4757;
  color: white;
  padding: 12px;
  border-radius: 8px;
  margin-top: 15px;
  font-size: 14px;
  text-align: center;
  display: none;
}

/* Header with user info */
.header {
  text-align: center;
  margin-bottom: 40px;
  color: white;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.header h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header p {
  font-size: 1.2rem;
  opacity: 0.9;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px 15px;
  border-radius: 25px;
  backdrop-filter: blur(10px);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.user-info span {
  font-weight: 600;
  color: white;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.generator-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.input-group {
  margin-bottom: 25px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #555;
}

.prompt-input {
  width: 100%;
  padding: 15px;
  border: 2px solid #e1e5e9;
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.3s ease;
  resize: vertical;
  min-height: 100px;
}

.prompt-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.drop-zone {
  border: 3px dashed #ccc;
  border-radius: 15px;
  padding: 40px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  background: #f8f9fa;
  position: relative;
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
  transform: translateY(-2px);
}

.drop-zone-content {
  pointer-events: none;
}

.drop-zone p {
  margin: 10px 0;
  font-size: 16px;
  color: #666;
}

.drop-zone .upload-icon {
  font-size: 48px;
  color: #667eea;
  margin-bottom: 15px;
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.preview-container {
  margin-top: 15px;
  text-align: center;
}

.preview-image {
  max-width: 300px;
  max-height: 200px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.remove-image {
  background: #ff4757;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  margin-top: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s ease;
}

.remove-image:hover {
  background: #ff3742;
}

.generate-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

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

.loading {
  display: none;
  text-align: center;
  margin: 20px 0;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

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

.gallery-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 30px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e1e5e9;
}

.gallery-header h2 {
  color: #333;
  font-size: 1.8rem;
}

.clear-gallery {
  background: #ff4757;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s ease;
}

.clear-gallery:hover {
  background: #ff3742;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  margin-top: 20px;
}

.gallery-item {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.gallery-image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  cursor: pointer;
}

.gallery-info {
  padding: 15px;
}

.gallery-prompt {
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
  line-height: 1.4;
}

.gallery-meta {
  font-size: 12px;
  color: #999;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px; /* Add some spacing between the buttons */
}

.download-btn,
.remix-btn {
  background: none;
  color: #667eea;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  transition: background 0.3s ease;
}

.download-btn:hover,
.remix-btn:hover,
.delete-btn:hover {
  background: rgba(102, 126, 234, 0.1);
}

.delete-btn {
  background: none;
  color: #ff4757;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  transition: background 0.3s ease;
}

.delete-btn:hover {
  background: rgba(255, 71, 87, 0.1);
}

.error-message {
  background: #ff4757;
  color: white;
  padding: 15px;
  border-radius: 10px;
  margin: 15px 0;
  display: none;
}

.success-message {
  background: #2ed573;
  color: white;
  padding: 15px;
  border-radius: 10px;
  margin: 15px 0;
  display: none;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 90vw;
  max-height: 90vh;
}

.modal-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
}

.close:hover {
  opacity: 0.7;
}

/* Google Sign-In Button Styling */
.g_id_signin {
  margin: 10px 0;
  width: 100% !important;
}

/* SSO Button Base Styles */
.sso-btn {
  width: 100%;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px; /* Space between SSO buttons */
}

.sso-logo {
  width: 24px;
  height: 24px;
}

/* Microsoft SSO Button Specific Styles */
.microsoft-sso-btn {
  background-color: #2f2f2f; /* Dark grey/black for Microsoft */
  color: white;
  border: 1px solid #2f2f2f;
}

.microsoft-sso-btn:hover {
  background-color: #000000;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header h1 {
    font-size: 2rem;
  }

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

  .user-menu {
    justify-content: center;
  }

  .generator-section,
  .gallery-section {
    padding: 20px;
  }

  .gallery {
    grid-template-columns: 1fr;
  }

  .auth-modal-content {
    padding: 30px 20px;
    margin: 20px;
  }

  .auth-header h2 {
    font-size: 1.5rem;
  }
}

/* Safety Tolerance Styles */
.safety-tolerance-container {
  margin-bottom: 25px;
}

.safety-tolerance-container label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #555;
}

.safety-tolerance-container select {
  width: 100%;
  padding: 15px;
  border: 2px solid #e1e5e9;
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.3s ease;
  appearance: none; /* Remove default arrow */
  background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23667eea"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 20px;
}

.safety-tolerance-container select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Styles for the new image icons within buttons */
.remix-btn img,
.download-btn img,
.delete-btn img {
  width: 20px;
  height: 20px;
  vertical-align: middle; /* Align icon vertically with text/other elements if any */
}
