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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #121212;
  color: #e0e0e0;
  line-height: 1.6;
}

#root {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem;
  background-color: #1e1e1e;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
}

.container {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

header {
  text-align: center;
  border-bottom: 1px solid #333;
  padding-bottom: 1.5rem;
}

header h1 {
  font-size: 2.5rem;
  color: #ffffff;
  margin-bottom: 0.5rem;
}

header p {
  font-size: 1.1rem;
  color: #a0a0a0;
  max-width: 600px;
  margin: 0 auto;
}

.header-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.headline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}

.auth-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background-color: #252525;
  border: 1px solid #333;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
}

.auth-username {
  font-size: 0.95rem;
  color: #d0d0d0;
}

.role-badge {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background-color: #333;
  color: #fff;
  text-transform: capitalize;
}

.role-badge.role-admin {
  background-color: #a855f7;
}

.role-badge.role-user {
  background-color: #00a884;
}

.logout-button {
  background: transparent;
  border: 1px solid #555;
  color: #f0f0f0;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s;
}

.logout-button:hover:not(:disabled) {
  background-color: #333;
  border-color: #777;
}

.logout-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (min-width: 768px) {
  .header-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .headline {
    text-align: left;
    align-items: flex-start;
  }

  header {
    text-align: left;
  }
}

.step {
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid #444;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.step-number {
    background-color: #007bff;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.step-header h2 {
    font-size: 1.8rem;
    color: #f5f5f5;
}

.step-description {
  color: #a0a0a0;
  margin-top: -1.5rem; /* Pulls it closer to the header */
  margin-bottom: 1rem;
  text-align: left;
}


.upload-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.image-upload {
  border: 2px dashed #555;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* Align items to the start */
  background-color: #252525;
  transition: border-color 0.3s, background-color 0.3s;
  min-height: 200px;
}


.image-upload:hover {
    border-color: #007bff;
    background-color: #2c2c2c;
}

.image-upload h3 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
  color: #f0f0f0;
}

.image-upload input[type="file"] {
  display: none;
}

.upload-label {
  cursor: pointer;
  background-color: #007bff;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 500;
  transition: background-color 0.3s;
  display: inline-block;
  margin-top: 1rem;
}

.image-upload .upload-label {
  margin-top: auto;
}
.image-upload.has-textarea .upload-label {
  margin-top: 1rem;
}


.upload-label:hover {
  background-color: #0056b3;
}

.image-preview-container {
  margin-top: 1rem;
  position: relative;
  width: 100%;
  max-width: 200px;
}

.image-preview {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid #444;
  object-fit: cover;
}

.remove-button {
  position: absolute;
  top: -10px;
  right: -10px;
  background-color: #dc3545;
  color: #fff;
  border: 2px solid #1e1e1e;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: background-color 0.3s, transform 0.2s;
  z-index: 10;
}

.remove-button:hover {
  background-color: #c82333;
  transform: scale(1.1);
}

.product-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    width: 100%;
    margin-top: auto;
}

.product-images-grid .image-preview-container {
    margin-top: 0;
    max-width: none;
}

.product-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: #333;
    padding: 0.75rem;
    border-radius: 8px;
}

.placement-input {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #555;
    background-color: #252525;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.placement-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

.generate-section {
  text-align: center;
  padding-top: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.generate-section.nested {
  padding-top: 0.5rem;
  justify-content: flex-end;
}

.generate-section.nested .secondary-button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
}

.generate-button, .start-over-button, .secondary-button {
  color: #fff;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s, box-shadow 0.3s, border-color 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.generate-button {
  background-color: #28a745;
}

.generate-button:hover:not(:disabled) {
  background-color: #218838;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.credit-button {
  background-color: #0077cc;
}

.credit-button:hover:not(:disabled) {
  background-color: #005fa3;
}

.generate-button:disabled, .secondary-button:disabled {
  background-color: #555;
  color: #999;
  cursor: not-allowed;
  box-shadow: none;
}

.start-over-button {
    background-color: #007bff;
}

.start-over-container {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
}


.start-over-button:hover {
    background-color: #0056b3;
}

.secondary-button {
  background-color: #3a3a3a;
  border: 1px solid #555;
}

.secondary-button:hover:not(:disabled) {
  background-color: #4a4a4a;
  border-color: #777;
}

.secondary-button:disabled {
  background-color: #2a2a2a;
  color: #777;
  border-color: #444;
}

.suggestion-button {
    margin-bottom: 1rem;
    align-self: flex-start; /* Aligns button to the left */
    padding: 0.75rem 1.5rem; /* Make it smaller than main button */
    font-size: 1rem;
}

.prompt-inputs {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 2rem;
}

.prompt-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.prompt-group label {
  font-weight: 600;
  color: #f0f0f0;
  font-size: 1.1rem;
}

.prompt-label-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.prompt-label-group .secondary-button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.prompt-group textarea,
.prompt-group select,
.json-textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid #555;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  background-color: #252525;
  color: #e0e0e0;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.prompt-group textarea,
.json-textarea {
  resize: vertical;
}

.prompt-group textarea:read-only {
  background-color: #202020;
  color: #a0a0a0;
  cursor: copy;
  border-color: #444;
}

.prompt-group select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e0e0e0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
}

.prompt-group textarea:focus,
.prompt-group select:focus,
.json-textarea:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

.aspect-ratio-note {
  font-size: 0.9rem;
  color: #a0a0a0;
  margin-top: 0.25rem;
}

.result-section {
  text-align: center;
}

.result-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border: 1px solid #444;
}

.loader {
  border: 6px solid #444;
  border-top: 6px solid #007bff;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

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

.error {
  color: #ff8a8a;
  margin-top: 1rem;
  font-weight: 500;
  text-align: center;
  background-color: rgba(220, 53, 69, 0.2);
  border: 1px solid #dc3545;
  padding: 1rem;
  border-radius: 8px;
}

.error a {
  color: #ffc107;
  text-decoration: underline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.tab-container {
  display: flex;
  width: 100%;
  border-bottom: 2px solid #555;
  margin: -1.5rem -1.5rem 1.5rem -1.5rem; /* Span across padding */
  width: calc(100% + 3rem); /* Span across padding */
}

.tab-button {
  flex-grow: 1;
  padding: 0.75rem 0.5rem;
  background-color: transparent;
  border: none;
  color: #a0a0a0;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: color 0.3s, border-color 0.3s;
}

.tab-button:hover {
  color: #fff;
}

.tab-button.active {
  color: #007bff;
  border-bottom-color: #007bff;
}

.json-instructions {
  color: #a0a0a0;
  font-size: 0.9rem;
  width: 100%;
  text-align: center;
  margin-bottom: 1rem;
}

.json-textarea {
  margin-top: 1.5rem;
}

/* Presets Section */
.presets-section .step-number {
  background-color: #ffc107;
  color: #1e1e1e;
}

.presets-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preset-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #333;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  border: 1px solid #4a4a4a;
}

.preset-name {
  font-size: 1.1rem;
  font-weight: 500;
  color: #f0f0f0;
}

.preset-actions {
  display: flex;
  gap: 0.75rem;
}

.preset-button {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.3s, border-color 0.3s;
}

.preset-button.load {
  background-color: #007bff;
  color: #fff;
  border-color: #007bff;
}

.preset-button.load:hover {
  background-color: #0056b3;
}

.preset-button.delete {
  background-color: #dc3545;
  color: #fff;
  border-color: #dc3545;
}

.preset-button.delete:hover {
  background-color: #c82333;
}

/* Video Generation */
.api-key-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background-color: #333;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #4a4a4a;
}
.api-key-section p {
    color: #ccc;
    font-size: 0.9rem;
}
.api-key-section a {
    color: #00aaff;
    text-decoration: none;
}
.api-key-section a:hover {
    text-decoration: underline;
}

.video-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem;
    border: none;
}
.video-loader .spinner {
    border: 6px solid #444;
    border-top: 6px solid #007bff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
.video-loader p {
    color: #c0c0c0;
    font-size: 1.1rem;
    text-align: center;
}


.result-video {
  width: 100%;
  max-width: 800px;
  height: auto;
  border-radius: 8px;
  border: 1px solid #444;
  background-color: #111;
}

.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background-color: #1e1e1e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.login-card h1 {
  text-align: center;
  font-size: 2rem;
  color: #ffffff;
}

.login-subtitle {
  text-align: center;
  color: #a0a0a0;
  font-size: 1rem;
}

.login-status {
  text-align: center;
  color: #d0d0d0;
  font-size: 0.95rem;
}

.error-banner {
  background-color: #3d1d1d;
  border: 1px solid #a04c4c;
  color: #ffd7d7;
  padding: 0.75rem;
  border-radius: 6px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-weight: 500;
  color: #dcdcdc;
}

.login-field input {
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid #444;
  background-color: #202020;
  color: #f5f5f5;
  transition: border-color 0.3s, background-color 0.3s;
}

.login-field input:focus {
  outline: none;
  border-color: #007bff;
  background-color: #252525;
}

.login-button {
  padding: 0.85rem;
  border-radius: 6px;
  border: none;
  background-color: #007bff;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s, opacity 0.3s;
}

.login-button:not(:disabled):hover {
  background-color: #0056b3;
}

.login-button:disabled {
  background-color: #3a3a3a;
  cursor: not-allowed;
  opacity: 0.7;
}

.login-hint {
  font-size: 0.9rem;
  color: #a0a0a0;
  background-color: #181818;
  border: 1px dashed #333;
  border-radius: 6px;
  padding: 1rem;
}

.login-hint p + p {
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  #root {
    margin: 1rem;
    padding: 1rem;
  }
  header h1 {
    font-size: 2rem;
  }
  .step {
    padding: 1.5rem;
  }
  .preset-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}
