.aig-container {
  max-width: 900px;
  margin: 20px auto;
  padding: 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
  border-radius: 12px;
  direction: rtl;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.aig-header {
  text-align: center;
  margin-bottom: 20px;
}

.aig-header h2 {
  margin: 0 0 8px 0;
  font-size: 26px;
  font-weight: 700;
  color: #1a202c;
  letter-spacing: -0.5px;
}

.aig-subtitle {
  margin: 0;
  color: #718096;
  font-size: 14px;
  line-height: 1.4;
}

/* Added promotional banner styling with gradient background and engaging design */
.aig-promo-banner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fef5e7 0%, #fdebd0 100%);
  border: 2px solid #f7dc6f;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(247, 220, 111, 0.2);
}

.aig-promo-icon {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
}

.aig-promo-content {
  flex: 1;
}

.aig-promo-content strong {
  display: block;
  color: #875f08;
  font-size: 16px;
  margin-bottom: 6px;
  font-weight: 700;
}

.aig-promo-content p {
  margin: 0;
  color: #6c5414;
  font-size: 14px;
  line-height: 1.5;
}

.aig-promo-link {
  color: #667eea;
  font-weight: 600;
  text-decoration: underline;
  transition: all 0.2s ease;
}

.aig-promo-link:hover {
  color: #764ba2;
  text-decoration: none;
}

.aig-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.aig-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* added overflow visible and extra padding to prevent label text cutoff */
  overflow: visible;
  padding-top: 4px;
}

.aig-form-group label {
  font-weight: 600;
  color: #2d3748;
  /* increased font size to 18px and added more spacing to ensure text is fully visible */
  font-size: 18px;
  padding: 8px 0;
  margin-bottom: 8px;
  display: block;
  line-height: 1.6;
  min-height: 30px;
  overflow: visible;
  white-space: normal;
}

#aig-prompt {
  min-height: 80px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  resize: vertical;
  transition: all 0.2s ease;
  background-color: #fafafa;
}

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

/* Changed model selection from radio buttons to dropdown */
.aig-models {
  position: relative;
}

#aig-model-select {
  width: 100%;
  /* increased padding and line-height to prevent text cutoff in dropdown */
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.8;
  min-height: 48px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  background-color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* added explicit styling for option elements to ensure text is not cut */
#aig-model-select option {
  padding: 12px 8px;
  line-height: 1.8;
  font-size: 15px;
  min-height: 40px;
}

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

#aig-model-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Made image upload area much more compact */
.aig-image-upload-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aig-upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: #f7fafc;
  border: 1.5px dashed #cbd5e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  color: #4a5568;
}

.aig-upload-button:hover {
  border-color: #667eea;
  background: #edf2f7;
  color: #667eea;
}

.aig-upload-icon {
  font-size: 16px;
}

.aig-image-preview {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  max-width: 200px;
  max-height: 120px;
}

.aig-image-preview img {
  width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: cover;
  display: block;
}

.aig-remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.aig-remove-image:hover {
  background: rgba(197, 48, 48, 0.9);
  transform: scale(1.1);
}

/* Made credits much more compact and collapsible */
.aig-credits-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.aig-credits-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 6px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
  cursor: pointer;
  transition: all 0.2s ease;
  align-self: flex-start;
  font-size: 12px;
}

.aig-credits-display:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(102, 126, 234, 0.3);
}

.aig-credits-amount {
  font-size: 16px;
  font-weight: 700;
}

.aig-credits-label {
  font-size: 11px;
  opacity: 0.95;
}

.aig-credits-breakdown {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 11px;
  max-width: 280px;
}

.aig-credits-breakdown.show {
  display: flex;
}

.aig-credits-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  color: #4a5568;
}

.aig-credits-type {
  font-weight: 500;
}

.aig-credits-row span:last-child {
  font-weight: 700;
  color: #2d3748;
}

.aig-credits-bonus {
  color: #38a169;
  background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 50%);
  padding: 4px 8px;
  margin: 0 -4px;
  border-radius: 4px;
}

.aig-credits-bonus span:last-child {
  color: #38a169;
}

.aig-credits-bonus::after {
  content: "🎁";
  margin-right: 4px;
  font-size: 12px;
}

/* Added purchase credits button styling inside breakdown */
.aig-buy-credits-button {
  display: block;
  text-align: center;
  padding: 8px 12px;
  margin-top: 8px;
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.aig-buy-credits-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(72, 187, 120, 0.3);
}

.aig-button {
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.aig-button-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.25);
}

.aig-button-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(102, 126, 234, 0.35);
}

.aig-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Completely redesigned status messages for better UX */
.aig-status {
  margin-top: 8px;
}

.aig-error {
  color: #c53030;
  background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
  border: 1px solid #fc8181;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(197, 48, 48, 0.1);
}

.aig-error::before {
  content: "⚠️";
  font-size: 18px;
}

.aig-success {
  color: #2f855a;
  background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
  border: 1px solid #68d391;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(47, 133, 90, 0.1);
}

.aig-success::before {
  content: "✓";
  font-size: 20px;
  font-weight: 700;
}

.aig-loading {
  color: #2b6cb0;
  background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
  border: 1px solid #90cdf4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}

.aig-loading::before {
  content: "⏳";
  font-size: 18px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.aig-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.aig-image {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  background: white;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.aig-image:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.aig-image img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}

.aig-image-info {
  padding: 14px;
  background: white;
}

.aig-image-prompt {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: #718096;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.5;
}

.aig-image-model {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #667eea;
  background: #edf2f7;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* Added action buttons for download and Lumise */
.aig-image-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.aig-image-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.aig-button-download {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #e2e8f0;
}

.aig-button-download:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
  transform: translateY(-1px);
}

.aig-button-lumise {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
}

.aig-button-lumise:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.aig-no-images {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #a0aec0;
  font-size: 15px;
}

.aig-login-prompt {
  text-align: center;
  padding: 50px 40px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.aig-login-prompt h2 {
  margin: 0 0 16px 0;
  color: #1a202c;
  font-size: 24px;
  font-weight: 700;
}

.aig-login-prompt p {
  margin: 0 0 24px 0;
  color: #718096;
  font-size: 15px;
  line-height: 1.6;
}

/* Added wrapper for social login to ensure center alignment */
.aig-social-login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
}

/* More compact mobile styles */
@media (max-width: 768px) {
  .aig-container {
    padding: 12px;
    margin: 8px;
    border-radius: 10px;
  }

  .aig-header {
    margin-bottom: 14px;
  }

  .aig-header h2 {
    font-size: 20px;
    margin-bottom: 4px;
  }

  .aig-subtitle {
    font-size: 12px;
  }

  /* Made promo banner more compact on mobile */
  .aig-promo-banner {
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 14px;
  }

  .aig-promo-icon {
    font-size: 24px;
  }

  .aig-promo-content strong {
    font-size: 14px;
    margin-bottom: 4px;
  }

  .aig-promo-content p {
    font-size: 12px;
  }

  .aig-form {
    padding: 14px;
    gap: 12px;
  }

  .aig-form-group {
    gap: 6px;
  }

  .aig-form-group label {
    font-size: 12px;
  }

  #aig-prompt {
    min-height: 60px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .aig-model-option {
    padding: 10px 12px;
  }

  .aig-model-name {
    font-size: 13px;
  }

  .aig-model-desc {
    font-size: 11px;
  }

  .aig-credits-display {
    padding: 5px 10px;
    gap: 5px;
  }

  .aig-credits-amount {
    font-size: 14px;
  }

  .aig-credits-label {
    font-size: 10px;
  }

  .aig-credits-breakdown {
    padding: 6px 10px;
    font-size: 10px;
  }

  .aig-button {
    padding: 9px 16px;
    font-size: 13px;
  }

  .aig-upload-button {
    padding: 6px 10px;
    font-size: 12px;
  }

  .aig-image-preview {
    max-width: 150px;
    max-height: 90px;
  }

  .aig-image-preview img {
    max-height: 90px;
  }

  .aig-error,
  .aig-success,
  .aig-loading {
    font-size: 12px;
    padding: 10px 14px;
  }

  .aig-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 16px;
  }

  .aig-image img {
    height: 140px;
  }

  .aig-image-info {
    padding: 8px;
  }

  .aig-image-prompt {
    font-size: 11px;
  }

  .aig-image-actions {
    flex-direction: column;
    gap: 6px;
  }

  .aig-image-button {
    padding: 7px 10px;
    font-size: 11px;
  }
}

/* Extra compact for very small screens */
@media (max-width: 480px) {
  .aig-container {
    padding: 10px;
    margin: 4px;
  }

  .aig-header h2 {
    font-size: 19px;
  }

  .aig-subtitle {
    font-size: 12px;
  }

  /* Further compacted promo on very small screens */
  .aig-promo-banner {
    padding: 10px 14px;
    gap: 8px;
  }

  .aig-promo-icon {
    font-size: 20px;
  }

  .aig-promo-content strong {
    font-size: 13px;
  }

  .aig-promo-content p {
    font-size: 11px;
  }

  .aig-form {
    padding: 14px;
    gap: 12px;
  }

  #aig-prompt {
    min-height: 60px;
  }

  .aig-model-option {
    padding: 8px 10px;
  }

  .aig-credits-amount {
    font-size: 16px;
  }

  .aig-credits-label {
    font-size: 11px;
  }

  .aig-button {
    padding: 10px 18px;
    font-size: 13px;
  }

  .aig-gallery {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }

  .aig-image img {
    height: 110px;
  }
}

/* Added styles for tabs and gallery in Lumise modal */
.lumise-ai-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
}

.lumise-ai-tab {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #64748b;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.lumise-ai-tab:hover {
  color: #667eea;
  background: #f8fafc;
}

.lumise-ai-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  font-weight: 600;
}

.lumise-ai-tab-content {
  display: none;
}

.lumise-ai-tab-content.active {
  display: block;
}

.lumise-ai-gallery-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.lumise-ai-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.lumise-ai-gallery-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #94a3b8;
  font-size: 14px;
}

.lumise-ai-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}

.lumise-ai-gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.lumise-ai-gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.lumise-ai-gallery-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.lumise-ai-gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.lumise-ai-gallery-item:hover .lumise-ai-gallery-overlay {
  opacity: 1;
}

.lumise-ai-gallery-use-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s;
}

.lumise-ai-gallery-use-btn:hover {
  transform: scale(1.05);
}

.lumise-ai-gallery-info {
  padding: 10px;
  background: white;
}

.lumise-ai-gallery-prompt {
  font-size: 12px;
  color: #475569;
  margin: 0 0 6px 0;
  line-height: 1.4;
  text-align: right;
}

.lumise-ai-gallery-model {
  display: inline-block;
  padding: 2px 8px;
  background: #e0e7ff;
  color: #667eea;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

@media (max-width: 768px) {
  .lumise-ai-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    max-height: 300px;
  }

  .lumise-ai-gallery-item img {
    height: 120px;
  }

  .lumise-ai-tabs {
    gap: 4px;
  }

  .lumise-ai-tab {
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* Added disabled state for FLUX model when no reference image */
.aig-model-option:has(input[type="radio"]:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.aig-model-option:has(input[type="radio"]:disabled):hover {
  border-color: #e2e8f0;
  background-color: white;
}
