:root {
  --primary-color: rgb(0, 160, 245);
  --secondary-color: #ffffff;
  --background-color: #f4f7f6; /* Lighter gray for a cleaner look */
  --text-color: #333333; /* Darker gray for better readability */
  --container-background: #ffffff;
  --border-color: #e0e0e0; /* Softer border color */
  --accent-color: #007bff; /* A complementary accent blue */
  --error-background: #ffebee;
  --error-text: #c62828;
  --success-background: #e8f5e9;
  --success-text: #2e7d32;

  --font-family-sans-serif: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-family-monospace: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo,
    monospace;

  --box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --border-radius: 0.3rem; /* Slightly more rounded corners */
}

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

body {
  font-family: var(--font-family-sans-serif);
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background-color: var(--primary-color);
  color: var(--secondary-color);
  padding: 1rem 0;
  box-shadow: var(--box-shadow);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.hamburger-menu {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1100;
}

.hamburger-bar {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px auto;
  background-color: #fff;
  transition: all 0.3s ease-in-out;
}

.auth-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.auth-links a,
.auth-links button,
.auth-links span {
  color: var(--secondary-color);
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.auth-links a:hover,
.auth-links button:hover {
  color: rgba(255,255,255,0.9);
  text-decoration: underline;
}

.auth-links a[href="/.auth/logout"] {
  display: none;
}
body.authenticated .auth-links a[href="/.auth/login/aad"] {
  display: none;
}
body.authenticated .auth-links a[href="/.auth/logout"] {
  display: inline-block;
}

/* Responsive menu for mobile */
@media (max-width: 768px) {
  .header-content {
    padding: 0 1rem;
  }
  .auth-links {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    right: 1rem;
    background-color: var(--container-background);
    width: 250px;
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    z-index: 1000;
    border: 1px solid var(--border-color);
  }
  .auth-links.open {
    display: flex;
  }
  .auth-links a,
  .auth-links button,
  .auth-links span {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1.5rem;
    text-align: left;
    color: var(--text-color) !important;
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
    border-radius: 0;
    transition: background-color 0.2s;
    min-height: 44px;
    box-sizing: border-box;
    margin: 0;
  }
  .auth-links a:hover,
  .auth-links button:hover {
    background-color: var(--background-color);
  }
  .auth-links > *:last-child {
    border-bottom: none;
  }
  .auth-links button {
    justify-content: flex-start;
  }
  .auth-links .dark-mode-toggle-button {
    width: 100%;
    justify-content: space-between;
  }
  .auth-links .dark-mode-toggle-button::before {
    content: 'Dark Mode';
    font-weight: 500;
  }
  .hamburger-menu {
    display: block;
  }
}

.header h1 {
  color: #ffffff; /* Ensure heading is white for better contrast on primary-color background */
  margin: 0;
}

.header .auth-links a {
  color: var(--secondary-color);
}

.header .auth-links a:hover {
  color: rgba(255, 255, 255, 0.9);
}

.main-content {
  flex: 1;
  padding: 2rem 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  background-color: var(--container-background);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-sm);
}

.footer {
  background-color: var(--container-background);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  text-align: center;
  color: var(--text-color);
}

.results {
  margin: 3rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  max-width: 800px;
  padding: 0 1rem;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  width: 100%;
}

.image-card {
  background: var(--container-background);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: var(--box-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0 auto;
  max-width: 512px;
  width: 100%;
}

.image-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--box-shadow);
}

.image-wrapper {
  width: 100%;
  height: 400px; /* Fixed height for all images to prevent scrolling */
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius);
  background-color: var(--background-color); /* Light background for letterboxing */
}

.image-wrapper img {
  display: block;
  width: 100%;
  height: 100%; /* Image takes up 100% of wrapper's height */
  object-fit: contain; /* Scales image to fit, preserving aspect ratio, no cropping */
  object-position: center; /* Centers the image within the wrapper */
  border-radius: var(--border-radius);
  transition: transform 0.3s ease;
}

.image-wrapper:hover img {
  transform: scale(1.02);
}

.image-card .download-btn {
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem;
  background-color: var(--primary-color);
  color: var(--secondary-color);
  border: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.image-card .download-btn:hover {
  background-color: #0086cc;
  transform: translateY(-2px);
}

.image-card .download-btn:active {
  transform: translateY(0);
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 0.75rem; /* Consistent bottom margin for headings */
  color: var(--primary-color); /* Headings in primary color */
  font-weight: 600; /* Bolder headings */
}

h1 {
  font-size: 2.25rem; /* Larger H1 */
}

.auth-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.hamburger-menu {
  display: none; /* Hidden by default on desktop */
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1100;
}

.hamburger-bar {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px auto;
  background-color: #fff;
  transition: all 0.3s ease-in-out;
}

.auth-links a {
  /* margin-left: 1rem; Removed as gap handles spacing */
  color: var(--accent-color); /* Using accent color for links */
  text-decoration: none;
  font-weight: 500; /* Slightly bolder links */
  transition: color 0.2s ease-in-out;
}

.auth-links a:hover {
  color: var(--primary-color); /* Primary color on hover */
  text-decoration: underline;
}

/* Hide logout by default */
.auth-links a[href="/.auth/logout"] {
  display: none;
}

/* When authenticated, hide login and show logout */
body.authenticated .auth-links a[href="/.auth/login/aad"] {
  display: none;
}

body.authenticated .auth-links a[href="/.auth/logout"] {
  display: inline-block; /* Use inline-block for better spacing control */
}

label {
  display: block; /* Labels on their own line for clarity */
  margin-bottom: 0.5rem;
  font-weight: 600; /* Bolder labels */
  color: var(--text-color);
}

textarea,
select,
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem; /* Consistent padding */
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--secondary-color);
  color: var(--text-color);
  transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

textarea:focus,
select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 160, 245, 0.25); /* Focus shadow with primary color */
}

textarea {
  resize: vertical;
  min-height: 120px; /* Minimum height for textarea */
}

button,
.button { /* Adding a .button class for elements that should look like buttons */
  display: inline-block; /* Allow side-by-side placement if needed */
  margin-top: 1.5rem; /* Increased top margin */
  padding: 0.85rem 1.75rem; /* Slightly larger padding */
  font-size: 1rem;
  font-weight: 600; /* Bolder button text */
  color: var(--secondary-color);
  background-color: var(--primary-color);
  border: 1px solid var(--primary-color); /* Border for consistency */
  border-radius: var(--border-radius);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

button:hover,
.button:hover {
  background-color: rgb(0, 140, 215); /* Darker shade of primary on hover */
  border-color: rgb(0, 140, 215);
}

button:disabled,
.button:disabled {
  opacity: 0.65; /* Slightly more visible when disabled */
  cursor: not-allowed;
  background-color: var(--border-color); /* Gray background for disabled */
  border-color: var(--border-color);
  color: #777;
}

/* Removed .button-secondary as it's not used by app.js or static HTML */

/* Unified alert message styles were merged into .error-message below */

.error-message {
  background-color: var(--error-background);
  border: 1px solid var(--error-text);
  color: var(--error-text);
  padding: 1.25rem; /* Specific padding */
  border-radius: var(--border-radius);
  margin: 1.5rem 0; /* Specific margin */
  font-size: 0.95rem; /* From former unified block */
  display: flex; /* From former unified block, for icon alignment */
  align-items: center; /* From former unified block, for icon alignment */
}

.error-main {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.error-details-container {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.error-details-toggle {
  background: transparent;
  border: 1px solid var(--error-text);
  color: var(--error-text);
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.error-details-toggle:hover {
  background-color: var(--error-text);
  color: var(--error-background);
}

.error-details-content {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* .success-message and .success-message::before removed as they are not used by app.js. */

.error-message::before {
  margin-right: 0.75rem;
  font-size: 1.2rem;
  content: "⚠️"; /* Combined content rule */
}

.image-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
  padding: 1.5rem;
  background-color: var(--background-color);
  border-radius: var(--border-radius);
}

.image-options .option-group { /* Grouping label and select */
    display: flex;
    flex-direction: column; /* Stack label on top of select */
    gap: 0.25rem; /* Small gap between label and select */
}
/* Remove previous #formatAndMultiImageGroup rules, restore default .option-group column layout */
#multiImageOptionContainer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    margin-top: 0;
    margin-bottom: 0;
    min-width: 180px;
}
#multiImageOptionContainer label {
    margin-bottom: 0;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    font-size: 1em;
}
#multiImageToggle {
    margin-bottom: 0.2em;
}

.image-options label {
  font-weight: 500; /* Normal weight for these labels */
  margin-right: 0; /* Remove right margin as they are stacked */
  margin-bottom: 0.25rem; /* Small bottom margin for label */
  color: var(--text-color);
}

.image-options select {
  padding: 0.65rem 0.85rem; /* Adjusted padding */
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.95rem; /* Slightly larger font */
  background-color: var(--secondary-color);
  cursor: pointer;
  min-width: 150px; /* Minimum width for select boxes */
}

.image-options select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 160, 245, 0.25);
}

.cost-estimate {
  display: none; /* Hide the cost estimate section since it's not needed */
}

.user-budget-info {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background-color: rgba(0, 160, 245, 0.1);
  border: 1px solid var(--primary-color);
  border-radius: var(--border-radius);
  font-size: 0.95rem;
  color: var(--primary-color);
  min-height: 60px; /* Prevent layout shift */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Removed unused budget/retry related classes:
.budget-info-content, .budget-item, .budget-loading, .budget-retry,
.retry-progress, .retry-count, .retry-timer, @keyframes retryProgress,
.budget-error, .budget-retry-button.
These were not found to be used by frontend/app.js.
Note: .budget-loading-indicator IS used and kept (defined elsewhere in HTML).
*/

/* Removed obsolete .spinner style block */

/* Removed unused utility classes: .text-center, .mt-*, .mb-* */

/* --- Style & Branding Selections --- */
#styleSelectorContainer,
#brandingOptionContainer {
    grid-column: 1 / -1;
}

#brandingOptionContainer > label:first-of-type {
    margin-bottom: 0.5rem;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.style-card {
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: var(--border-radius);
  overflow: hidden;
  position: relative;
  transition: all 0.2s ease-in-out;
  aspect-ratio: 1 / 1;
  background-color: #e0e0e0; /* Placeholder background */
}

.style-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease-in-out;
}

.style-card:hover img {
    transform: scale(1.05);
}

.style-card .style-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s ease-in-out;
  pointer-events: none; /* So it doesn't interfere with click */
  z-index: 1;
}

.style-card.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 8px rgba(0, 160, 245, 0.5);
}

.style-card.selected .style-name {
    background-color: var(--primary-color);
}

#brandingOptionContainer input[type="checkbox"] {
    display: none;
}

.branding-card {
    display: flex;
    align-items: center;
    padding: 1rem;
    background-color: var(--secondary-color);
    border: 3px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.branding-card:hover {
    border-color: var(--accent-color);
}

#brandingOptionContainer input[type="checkbox"]:checked + .branding-card {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(0, 160, 245, 0.5);
}

.branding-card-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
    color: var(--text-color);
    width: 100%;
}

.branding-card-content img {
    height: 32px;
    width: auto;
    flex-shrink: 0;
}

.selected-style-name {
    font-weight: 600;
    color: var(--primary-color);
    margin-left: 0.5rem;
    background-color: #eef8ff;
    padding: 0.2rem 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.9em;
}

.style-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 3rem;
    line-height: 1;
    color: #999;
    background-color: #f0f0f0;
}

.checkbox-icon-container {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background-color: #fff;
}

.checkbox-icon {
    width: 14px;
    height: 14px;
    background-color: transparent;
    border-radius: 50%;
    transition: all 0.2s ease;
    transform: scale(0);
}

#brandingOptionContainer input[type="checkbox"]:checked + .branding-card .checkbox-icon-container {
    border-color: var(--primary-color);
}

#brandingOptionContainer input[type="checkbox"]:checked + .branding-card .checkbox-icon {
    background-color: var(--primary-color);
    transform: scale(1);
}
/* Dark Mode Variable Overrides */
body.dark-mode {
  --primary-color: rgb(0, 160, 245); /* Accent color can remain the same */
  --secondary-color: #1e1e1e; /* Dark background for header, buttons */
  --background-color: #121212; /* Main page background */
  --text-color: #e0e0e0; /* Light text for readability */
  --container-background: #1e1e1e; /* Background for cards, containers */
  --border-color: #444444; /* Softer borders for dark theme */
  --accent-color: #00a0f5; /* A slightly brighter accent blue for dark bg */
  --error-background: #2c1d1d;
  --error-text: #ff8a80;
  --success-background: #1a2b1a;
  --success-text: #a5d6a7;
}

/* Ensure header text is readable in both modes */
.header {
    background-color: var(--primary-color);
    color: #ffffff; /* Explicitly set to white for high contrast */
}

.header .auth-links a {
    color: #ffffff;
}

/* Adjust modal for dark mode */
body.dark-mode .modal-content {
    background-color: var(--container-background);
    border: 1px solid var(--border-color);
}

body.dark-mode .close-button {
    color: #aaa;
}

body.dark-mode .close-button:hover,
body.dark-mode .close-button:focus {
    color: var(--text-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header-content {
    padding: 0 1rem;
  }

  .auth-links {
    display: none; /* Hide links by default on mobile */
    position: absolute;
    top: calc(100% + 5px); /* Position below the header with a small gap */
    right: 1rem; /* Align to the right */
    background-color: var(--container-background);
    width: 250px; /* Set a fixed width for the flyout */
    flex-direction: column;
    align-items: stretch; /* Stretch items to fill the width */
    padding: 0.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    z-index: 1000;
    border: 1px solid var(--border-color);
  }

  .auth-links.open {
    display: flex; /* Show links when menu is open */
  }

  .auth-links a,
  .auth-links button,
  .auth-links span {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1.5rem;
    text-align: left;
    color: var(--text-color) !important; /* Use theme text color */
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
    border-radius: 0; /* Remove individual radius for a list feel */
    transition: background-color 0.2s;
    min-height: 44px; /* Ensure consistent height */
    box-sizing: border-box;
    margin: 0; /* Reset margin */
  }

  .auth-links a:hover,
  .auth-links button:hover {
      background-color: var(--background-color);
  }
  
  .auth-links > *:last-child {
    border-bottom: none;
  }

  /* Specific overrides for buttons inside the flyout */
  .auth-links button {
    justify-content: flex-start; /* Align button content to the left */
  }

  .auth-links .dark-mode-toggle-button {
      width: 100%; /* Ensure it fills the space like other items */
      justify-content: space-between; /* Push icon to the right */
  }
  
  .auth-links .dark-mode-toggle-button::before {
      content: 'Dark Mode'; /* Add text label for the toggle */
      font-weight: 500;
  }

  .hamburger-menu {
    display: block; /* Show hamburger on mobile */
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }
  .container {
    padding: 1rem;
  }
  .header-content {
    padding: 0 0.25rem;
  }
  /* Hamburger menu already styled in 768px */
  button, .button {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
  }
  .image-gallery {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 1.2rem;
  }
}

/* Add a subtle animation to buttons on click */
button:active, .button:active {
  transform: translateY(1px);
  box-shadow: var(--box-shadow-sm);
}

/* Style for the prompt input area */
#prompt-container {
  margin: 2rem 0;
  padding: 1.5rem;
  background-color: var(--container-background);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-sm);
  border: 1px solid var(--border-color);
  position: relative; /* Needed for absolute positioning of enhance button */
}

#prompt-container label {
  font-size: 1.1rem;
  color: var(--primary-color);
}

#promptInput {
  min-height: 120px;
  resize: vertical;
  margin-top: 0.5rem;
}

/* Ensure consistent spacing for elements not directly styled above */
form div + div { /* Add space between stacked divs in a form, common pattern */
  margin-top: 1rem;
}

/* General link styling if any outside auth-links */
a {
  color: var(--accent-color);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  color: var(--primary-color);
}

#generateButton {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 2rem auto;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--secondary-color);
  background-color: var(--primary-color);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
  box-shadow: var(--box-shadow-sm);
}

#generateButton:hover {
  background-color: #0086cc;
  transform: translateY(-2px);
  box-shadow: var(--box-shadow);
}

#generateButton:active {
  transform: translateY(0);
}

#generateButton:disabled {
  background-color: var(--border-color);
  border-color: var(--border-color);
  color: #777;
  cursor: not-allowed;
  opacity: 0.6;
  transform: translateY(0); /* Prevent hover/active transform when disabled */
  box-shadow: var(--box-shadow-sm); /* Maintain consistent shadow */
}

/* Info Button Styles */
.info-button {
  background-color: var(--accent-color); /* Use accent color for consistency */
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}

.info-button:hover {
  background-color: var(--primary-color); /* Use primary color on hover */
}

/* Dark Mode Toggle Button Styles */
.dark-mode-toggle-button {
  background-color: var(--accent-color);
  color: var(--secondary-color);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; /* Fixed width for a square button */
  height: 40px; /* Fixed height for a square button */
  padding: 0; /* Remove padding to center icon */
  /* Align with text by using baseline alignment in parent flex */
  vertical-align: middle;
  box-sizing: border-box;
}


.dark-mode-toggle-button:hover {
  background-color: var(--primary-color);
}

.dark-mode-icon {
  font-size: 1.5em; /* Larger icon size */
  line-height: 1; /* Ensure icon sits well */
  display: block; /* Ensure it takes up full space */
}

/* Modal Styles */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1000; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto; /* 10% from the top and centered */
  padding: 20px;
  border: 1px solid #888;
  width: 60%; /* Could be more or less, depending on screen size */
  border-radius: 8px;
  position: relative;
}

.close-button {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close-button:hover,
.close-button:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

#modalBody h1, #modalBody h2, #modalBody h3 {
    margin-top: 0.5em;
    margin-bottom: 0.3em;
}

#modalBody p {
    margin-bottom: 0.5em;
}

#modalBody ul, #modalBody ol {
    margin-left: 20px;
    margin-bottom: 0.5em;
}

/* Removed obsolete .spinner style block */

/* Bouncing Dots Animation */
.loading-animation p {
  margin-top: 15px; /* Add some space above the text */
  font-style: italic;
}

.bouncing-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 50px; /* Adjust height as needed */
}

.bouncing-dots .dot {
  width: 12px; /* Size of the dots */
  height: 12px;
  background-color: var(--primary-color); /* Use your primary color */
  border-radius: 50%;
  margin: 0 5px; /* Space between dots */
  animation: bounce 1.4s infinite ease-in-out both;
}

.bouncing-dots .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.bouncing-dots .dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1.0);
  }
}

/* Ensure the main loading-animation container is still centered */
.loading-animation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

/* Removed commented out @keyframes spin */

/* --- Main layout for banner + card --- */
.main-layout {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  margin: 0 auto;
  max-width: 1800px;
}

.main-banner {
  flex: 0 0 240px; /* Reverted width from 300px */
  display: flex;
  align-items: center; /* Changed from flex-start to center */
  justify-content: center;
  min-width: 240px; /* Reverted width from 300px */
  max-width: 240px; /* Reverted width from 300px */
  margin-top: 0rem;
}

.main-banner img {
  width: 100%;
  height: auto;
  max-height: 600px;
  object-fit: contain;
  /* border-radius: var(--border-radius); Removed */
  /* box-shadow: var(--box-shadow-sm); Removed */
  /* background: #fff; Removed for SVG */
}

/* Make the main card narrower */
.main-layout .container {
  max-width: 1000px; /* Increased width for the card content */
  width: 100%;
  margin: 0;
}

/* Responsive: stack on small screens, hide banner if too small */
@media (max-width: 900px) {
  .main-layout {
    gap: 1rem;
    max-width: 100%;
  }
  .main-layout .container {
    max-width: 100%;
  }
  .main-banner {
    max-width: 90px;
    min-width: 90px;
  }
}

@media (max-width: 700px) {
  .main-layout {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  .main-banner {
    display: none; /* Hide banner on small screens */
    max-width: 120px;
    min-width: 60px;
    margin: 0 auto 1rem auto;
  }
  .main-banner img {
    max-height: 200px;
  }
}

/* Info icon for multi-image toggle */
#multiImageInfo {
  color: var(--primary-color);
  margin-left: 0.2em;
  cursor: pointer;
  font-size: 1.1em;
  user-select: none;
}
#multiImageInfo:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* --- Prompt Enhancement Styles --- */

/* 1. Small round enhance button, absolute top-right inside #prompt-container */
.enhance-btn {
  position: absolute;
  /* Place button overlapping the top-right corner of the prompt textarea */
  top: 38px; /* Adjust to overlap the prompt box, tweak as needed */
  right: 24px; /* Slightly inside the prompt box */
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--secondary-color);
  border: none;
  box-shadow: var(--box-shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  font-size: 1.2rem;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  /* Add a subtle border for contrast */
  border: 2px solid #fff;
}

@media (max-width: 700px) {
  .enhance-btn {
    top: 32px;
    right: 10px;
  }
}
.enhance-btn:hover,
.enhance-btn:focus {
  background: rgb(0, 140, 215);
  color: #fff;
  outline: none;
}
body.dark-mode .enhance-btn {
  background: var(--accent-color);
  color: #fff;
}

/* 2. Modern slide-in modal for prompt enhancement */
.enhance-preview {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.enhance-preview .card {
  background: var(--container-background);
  color: var(--text-color);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  padding: 1.5rem;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  position: relative;
  animation: slideIn 0.3s ease-out;
  border: 1px solid var(--border-color);
}

body.dark-mode .enhance-preview .card {
  background: var(--container-background);
  color: var(--text-color);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

/* Close button */
.enhance-preview .close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-color);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.enhance-preview .close-btn:hover {
  background-color: var(--border-color);
}

/* Modal header */
.enhance-preview h3 {
  margin: 0 2rem 1rem 0;
  color: var(--primary-color);
  font-size: 1.2rem;
  font-weight: 600;
}

/* Textarea sections */
.enhance-section {
  margin-bottom: 1.5rem;
}

.enhance-section label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-color);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.enhance-preview textarea {
  width: 100%;
  min-height: 100px;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 2px solid var(--border-color);
  background: var(--secondary-color);
  color: var(--text-color);
  resize: vertical;
  padding: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  line-height: 1.5;
}

.enhance-preview textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 160, 245, 0.1);
}

body.dark-mode .enhance-preview textarea {
  background: #1a1a1a;
  color: #e0e0e0;
  border-color: #444;
}

body.dark-mode .enhance-preview textarea:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0, 160, 245, 0.2);
}

/* Enhanced textarea (readonly) styling */
.enhance-preview textarea[readonly] {
  background: linear-gradient(135deg, rgba(0, 160, 245, 0.05), rgba(0, 160, 245, 0.02));
  border-color: var(--primary-color);
}

body.dark-mode .enhance-preview textarea[readonly] {
  background: linear-gradient(135deg, rgba(0, 160, 245, 0.1), rgba(0, 160, 245, 0.05));
}

/* 4. Modern button layout */
.preview-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.preview-buttons button {
  margin: 0;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  min-width: 100px;
}

.preview-buttons .btn-primary {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.preview-buttons .btn-primary:hover {
  background: rgb(0, 140, 215);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 160, 245, 0.3);
}

.preview-buttons .btn-secondary {
  background: transparent;
  color: var(--text-color);
  border-color: var(--border-color);
}

.preview-buttons .btn-secondary:hover {
  background: var(--border-color);
  transform: translateY(-1px);
}

.preview-buttons .btn-ghost {
  background: transparent;
  color: var(--text-color);
  border: none;
  opacity: 0.7;
}

.preview-buttons .btn-ghost:hover {
  opacity: 1;
  background: var(--border-color);
}

/* Loading state for buttons */
.preview-buttons button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
  .enhance-preview .card {
    width: 95%;
    padding: 1rem;
    margin: 1rem;
    max-height: 90vh;
  }
  
  .preview-buttons {
    flex-direction: column;
  }
  
  .preview-buttons button {
    width: 100%;
  }
}

/* 5. Hide with .hidden (already exists) */
/* Hide elements with .hidden */
.hidden {
  display: none !important;
}
