/* Basic Reset & Box Sizing */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  background-color: #f3f4f6;
  color: #333;
  /* Prevent horizontal scroll on small devices */
  overflow-x: hidden;
}

/* Main & Favorite Containers */
.main-container,
.favorite-main-container {
  width: 95%;
  max-width: 1250px;
  margin: 1rem auto;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

.title-h {
  font-size: 1.4rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: #6b7280;
}

/* Generator Grid Layout */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 768px) {
  .generator-grid {
    grid-template-columns: 1fr;
  }
}

/* Form Section */
.form-section {
  padding: 1rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  background-color: #fff;
}
.form-section label {
  display: block;
  font-weight: bold;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: #374151;
}
.form-section input[type="text"],
.form-section select,
.form-section textarea {
  width: 100%;
  padding: 0.45rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
  border: 1px solid #d1d5db;
}

/* Relative & Word Count */
.relative {
  position: relative;
}
.word-count {
  text-align: right;
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: -0.4rem;
  margin-bottom: 0.6rem;
}
/* Random Button */
#randomContextBtn {
  position: absolute;
  right: 0.4rem;
  top: 2.05rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #6b7280;
  transition: color 0.2s;
}
#randomContextBtn:hover {
  color: #000;
}

/* Collapsible Advanced Options */
.collapsible-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0 0.5rem 0;
  font-weight: bold;
  font-size: 0.9rem;
  color: #374151;
}
.collapsible-body {
  display: none;
  margin-bottom: 1rem;
}

/* Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background-color: #a78bfa;
}
input[type="range"]::-webkit-slider-thumb {
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: #7c3aed;
  margin-top: -5px;
  border: none;
  -webkit-appearance: none;
}
#sliderValue {
  font-size: 0.75rem;
  color: #7c3aed;
  font-style: italic;
  margin-bottom: 1rem;
  display: inline-block;
}

/* Buttons */
.bg-gradient {
  background: linear-gradient(90deg, #553c9a, #ee4b2b) !important;
  color: #fff !important;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bg-gradient:hover {
  transform: scale(1.02);
  opacity: 0.9;
}
.button-container {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}

/* Result Section */
.result-section {
  min-height: 400px;
  padding: 1rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  background-color: #fff;
}
#loadingIndicator {
  display: none;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
  min-height: 40px;
}
.loader {
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-left-color: #000;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
#placeholderPreview {
  color: #666;
  font-style: italic;
  margin-top: 1rem;
}

/* Real-Time Chat Preview (For generated messages) */
.chat-preview {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 500px;
  overflow-y: auto;
}
.chat-bubble {
  padding: 0.5rem 0.75rem;
  border-radius: 16px;
  max-width: 70%;
  word-wrap: break-word;
  font-size: 0.85rem;
  line-height: 1.3;
  position: relative;
}
.chat-bubble.sent {
  align-self: flex-end;
  background-color: #dcf8c6;
}
.chat-bubble.received {
  align-self: flex-start;
  background-color: #f1f0f0;
}
.bubble-actions {
  top: 4px;
  right: 6px;
  display: flex;
  gap: 0.3rem;
}
.btn-icon {
  background: none;
  border: none;
  padding: 0.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s;
  color: #374151;
}
.btn-icon:hover {
  color: #000;
}

/* Toast Notification */
.toast {
  visibility: hidden;
  position: fixed;
  left: 50%;
  bottom: -60px;
  transform: translateX(-50%);
  background-color: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
  transition: all 0.5s ease;
  z-index: 9999;
}
.toast.show {
  visibility: visible;
  bottom: 20px;
}

/* Favorites Section */
.favorite-main-container {
  width: 95%;
  max-width: 1250px;
  margin: 1rem auto;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
  padding: 1rem;
  background-color: #fff;
}
.favorite-section h2 {
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #374151;
}
.favorite-list {
  margin-top: 1rem;
}
.combine-section {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  background-color: #ebf8ff;
  border: 1px solid #bee3f8;
}
.combine-section textarea {
  width: 100%;
  min-height: 60px;
  margin-top: 0.3rem;
  resize: vertical;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.8rem;
  padding: 0.4rem;
}

.hidden {
  display: none !important;
}

/* Step Sections (if applicable) */
.step {
  background-color: #f9f9f9;
  padding: 20px;
}
@media screen and (max-width: 768px) {
  .step {
    padding: 15px;
    margin-bottom: 20px;
    max-width: 100%;
    overflow-x: hidden;
  }
}
.step-description {
  font-size: 16px;
  color: #666;
}
