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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
  color: #ffffff;
  height: 100vh;
  overflow-x: hidden; 
}

.container {
  display: flex;
  height: 100%;
}

/* Left Sidebar - Presets & Actions */
.left-sidebar {
  width: 280px;
  background: linear-gradient(180deg, #1e1e1e 0%, #161616 100%);
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: 2px 0 10px rgba(0,0,0,0.3);
}

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

.logo h1 {
  font-size: 1.8rem;
  background: linear-gradient(45deg, #667eea, #764ba2, #f093fb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  margin-bottom: 5px;
}

.logo p {
  color: #888;
  font-size: 0.9rem;
}

.section {
  margin-bottom: 25px;
}

.section h3 {
  font-size: 1.1rem;
  color: #667eea;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preset-btn {
  background: linear-gradient(135deg, #2a2a2a, #3a3a3a);
  border: 1px solid #444;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  text-align: left;
}

.preset-btn:hover {
  background: linear-gradient(135deg, #3a3a3a, #4a4a4a);
  border-color: #667eea;
  transform: translateY(-2px);
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.action-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.action-btn.download { background: linear-gradient(135deg, #28a745, #20c997); }
.action-btn.save { background: linear-gradient(135deg, #ffc107, #fd7e14); }
.action-btn.share { background: linear-gradient(135deg, #6f42c1, #e83e8c); }

/* Right Sidebar - Configuration */
.right-sidebar {
  width: 320px;
  background: linear-gradient(180deg, #1a1a1a 0%, #141414 100%);
  border-left: 1px solid #333;
  padding: 20px;
  overflow-y: auto;
  box-shadow: -2px 0 10px rgba(0,0,0,0.3);
}

.config-section {
  margin-bottom: 25px;
}

.config-section h3 {
  font-size: 1.1rem;
  color: #667eea;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: #ccc;
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  background: #333;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.rule-input {
  min-height: 80px;
  resize: vertical;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
}

.julia-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
  position: relative;
}

.image-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#output {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  transition: all 0.5s ease;
}

.generate-btn {
  position: sticky;
  bottom: 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  color: white;
  padding: 15px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.generate-btn:hover {
  background: linear-gradient(135deg, #764ba2, #667eea);
  box-shadow: 0 -4px 20px rgba(102, 126, 234, 0.4);
}

/* Spinner */
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border: 4px solid #333;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Scrollbar */
.right-sidebar::-webkit-scrollbar {
  width: 6px;
}

.right-sidebar::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.right-sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 3px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #2a2a2a;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-content h2 {
  color: #fff;
  margin-bottom: 20px;
}

.modal-content button {
  background: linear-gradient(135deg, #dc3545, #c82333);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 15px;
}

/* --- Add these new styles to your style.css file --- */

/* Container for each favorite item */
.favorite-item {
  position: relative; /* Crucial for positioning the delete button */
  border: 1px solid #444;
  border-radius: 8px;
  overflow: hidden; /* Clips the image to the rounded corners */
  cursor: pointer;
  transition: all 0.3s ease;
  background: #2a2a2a;
}

.favorite-item:hover {
  border-color: #667eea;
  transform: translateY(-3px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Add these styles for the welcome message */
#welcome-message {
  text-align: center;
  color: #888;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
}

#welcome-message h2 {
  font-size: 1.5rem;
  color: #ddd;
  margin-bottom: 10px;
  background: linear-gradient(45deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#welcome-message p {
  font-size: 1rem;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.5;
}
/* The preview image itself */
.favorite-preview {
  width: 100%; /* Make the image fill the container's width */
  height: 120px; /* Give all thumbnails a fixed, uniform height */
  object-fit: cover; /* This is the magic part! It scales the image to fill the space without distorting it. */
  display: block; /* Removes any extra space below the image */
}

/* The name of the favorite */
.favorite-name {
  padding: 8px;
  font-size: 0.85rem;
  text-align: center;
  color: #ccc;
  /* Prevent long names from breaking the layout */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The little 'x' button to delete a favorite */
.delete-favorite {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2; /* Ensure it's on top of the image */
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.delete-favorite:hover {
  background: #dc3545; /* Red on hover */
  transform: scale(1.1);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  width: max-content;
  transform: translateX(-50%);
  padding: 12px 25px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 2000;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.4s ease, bottom 0.4s ease;
  animation: slideIn 0.5s forwards;
}

.toast.success {
  background: linear-gradient(135deg, #28a745, #20c997);
}

.toast.error {
  background: linear-gradient(135deg, #dc3545, #c82333);
}

@keyframes slideIn {
  from {
    bottom: -50px;
    opacity: 0;
  }
  to {
    bottom: 20px;
    opacity: 1;
  }
}

@media (max-width: 768px) {
  body {
    height: auto;
    overflow-y: auto;
    padding-bottom: 80px; 
  }

  .container {
    flex-direction: column;
    height: auto;
  }

  .main-content {
    order: 1;
    min-height: 45vh; 
    flex-grow: 1;
  }

  .left-sidebar {
    order: 2; /* Second item */
  }

  .right-sidebar {
    order: 3; /* Third item */
  }
  
  .left-sidebar,
  .right-sidebar {
    width: 100%;
    height: auto; /* Let height be determined by content */
    max-height: none;
    border-right: none;
    border-left: none;
    border-bottom: 1px solid #333;
    overflow-y: visible; /* Let the main page handle scrolling */
    padding: 20px 15px;
  }
  
  .image-container {
    padding: 15px;
  }

  .generate-btn {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    border-radius: 0;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.5);
  }

  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .preset-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .logo h1 {
    font-size: 1.5rem;
  }
}
