/* ============================================
   Banner Studio - Styles
   ============================================ */

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

:root {
  --primary: #667eea;
  --primary-dark: #5a6fd8;
  --secondary: #764ba2;
  --success: #38a169;
  --danger: #e53e3e;
  --warning: #dd6b20;
  --info: #3182ce;
  --gray-50: #f7fafc;
  --gray-100: #edf2f7;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-400: #a0aec0;
  --gray-500: #718096;
  --gray-600: #4a5568;
  --gray-700: #2d3748;
  --gray-800: #1a202c;
  --white: #ffffff;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white);
  padding: 30px 20px;
  text-align: center;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Main Container */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

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

.screen h2 {
  font-size: 1.8rem;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.screen-description {
  color: var(--gray-500);
  margin-bottom: 30px;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

/* Back Button */
.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  color: var(--gray-600);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.back-btn:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.back-icon {
  font-size: 1.2rem;
}

/* Category Badge */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white);
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Categories Grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.category-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: 16px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
}

.category-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.category-card .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.category-card h3 {
  font-size: 1.2rem;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.category-card .description {
  color: var(--gray-500);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.category-card .dimensions {
  display: inline-block;
  padding: 4px 10px;
  background: var(--gray-100);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--gray-600);
}

/* Generation Form */
.generation-form {
  background: var(--white);
  border-radius: 16px;
  padding: 30px;
  box-shadow: var(--shadow);
}

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

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.form-group .required {
  color: var(--danger);
}

.form-group input[type="text"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: rgba(102, 126, 234, 0.05);
}

.upload-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 10px;
}

.upload-hint,
.field-hint {
  font-size: 0.85rem;
  color: var(--gray-400);
  margin-top: 8px;
}

.browse-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* Reference Preview */
.reference-preview {
  position: relative;
  display: inline-block;
  margin-top: 15px;
}

.reference-preview img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 10px;
  object-fit: cover;
}

.remove-reference {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: var(--danger);
  color: var(--white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

/* Multi-Photo Upload */
.reference-photos-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.photo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
}

.photo-row .photo-preview {
  width: 80px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-row .photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-row .photo-preview .upload-placeholder {
  font-size: 1.5rem;
  color: var(--gray-400);
}

.photo-row .photo-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-row .purpose-select {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--white);
}

.photo-row .custom-purpose {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  display: none;
}

.photo-row .custom-purpose.visible {
  display: block;
}

.photo-row .remove-photo-btn {
  width: 32px;
  height: 32px;
  background: var(--danger);
  color: var(--white);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.photo-row .remove-photo-btn:hover {
  opacity: 0.9;
}

.add-photo-btn {
  padding: 10px 16px;
  background: var(--gray-100);
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  color: var(--gray-600);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.add-photo-btn:hover {
  background: var(--gray-200);
  border-color: var(--primary);
  color: var(--primary);
}

/* Buttons */
.generate-btn,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.generate-btn:hover,
.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.generate-btn:disabled,
.action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.action-btn {
  width: auto;
}

.action-btn.secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 2px solid var(--gray-300);
}

.action-btn.secondary:hover {
  background: var(--gray-100);
}

/* Progress Section */
.progress-section {
  margin-top: 30px;
  padding: 20px;
  background: var(--gray-100);
  border-radius: 12px;
}

.progress-bar {
  height: 8px;
  background: var(--gray-300);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  margin-top: 12px;
  color: var(--gray-600);
  font-size: 0.95rem;
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.result-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.preview-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 10;
}

.result-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.result-card.selected {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.3);
}

.result-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.result-card-actions {
  padding: 15px;
  display: flex;
  gap: 10px;
}

.result-card-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.iterate-btn {
  background: var(--primary);
  color: var(--white);
  border: none;
}

.iterate-btn:hover {
  background: var(--primary-dark);
}

.download-btn {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.download-btn:hover {
  background: var(--gray-100);
}

.results-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
}

/* Iteration Layout */
.iterate-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 30px;
}

.iterate-main {
  background: var(--white);
  border-radius: 16px;
  padding: 25px;
  box-shadow: var(--shadow);
}

.selected-image-container {
  margin-bottom: 20px;
}

.selected-image-container img {
  width: 100%;
  border-radius: 12px;
}

.refinement-form label {
  display: block;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}

.refinement-form textarea {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 1rem;
  resize: vertical;
  min-height: 100px;
  margin-bottom: 15px;
}

.refinement-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.refinement-actions {
  display: flex;
  gap: 10px;
}

/* Version History Sidebar */
.iterate-sidebar {
  background: var(--white);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.iterate-sidebar h3 {
  font-size: 1.1rem;
  color: var(--gray-700);
  margin-bottom: 15px;
}

.version-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
}

.version-item {
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.version-item:hover {
  border-color: var(--primary);
}

.version-item.active {
  border-color: var(--success);
}

.version-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.version-item .version-label {
  padding: 8px 10px;
  font-size: 0.85rem;
  color: var(--gray-600);
  background: var(--gray-50);
}

.iteration-count {
  padding: 6px 12px;
  background: var(--info);
  color: var(--white);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: 10px;
  color: var(--white);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.warning { background: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.modal.active {
  display: flex;
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}

.modal-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 12px;
}

.modal-close {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 36px;
  height: 36px;
  background: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* Responsive */
@media (max-width: 900px) {
  .iterate-layout {
    grid-template-columns: 1fr;
  }

  .iterate-sidebar {
    order: -1;
  }

  .version-history {
    flex-direction: row;
    overflow-x: auto;
  }

  .version-item {
    min-width: 150px;
  }
}

@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }

  .main-container {
    padding: 20px 15px;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .categories-grid {
    grid-template-columns: 1fr;
  }

  .results-actions {
    flex-direction: column;
  }

  .refinement-actions {
    flex-direction: column;
  }
}

/* ============================================
   Header Navigation
   ============================================ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.header-content {
  text-align: left;
}

.header-nav {
  display: flex;
  gap: 10px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Brand Selector
   ============================================ */

.brand-selector {
  display: flex;
  gap: 10px;
}

.brand-selector select {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 1rem;
}

.brand-selector select:focus {
  outline: none;
  border-color: var(--primary);
}

.brand-add-btn {
  width: 46px;
  height: 46px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.brand-add-btn:hover {
  background: var(--primary-dark);
}

.brand-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--gray-100);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.brand-preview-colors {
  display: flex;
  gap: 6px;
}

.brand-preview-colors .color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--white);
  box-shadow: var(--shadow);
}

.brand-preview-info {
  flex: 1;
}

.brand-preview-info .name {
  font-weight: 600;
  color: var(--gray-800);
}

.brand-preview-info .tagline {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ============================================
   Brand Management Screen
   ============================================ */

.brands-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.brands-list-section {
  background: var(--white);
  border-radius: 16px;
  padding: 25px;
  box-shadow: var(--shadow);
}

.brands-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.brands-list-header h3 {
  font-size: 1.2rem;
  color: var(--gray-700);
}

.brands-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
}

.brands-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.brand-card:hover {
  border-color: var(--primary);
  background: var(--white);
}

.brand-card.selected {
  border-color: var(--success);
  background: rgba(56, 161, 105, 0.05);
}

.brand-card-logo {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  overflow: hidden;
}

.brand-card-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-card-info {
  flex: 1;
}

.brand-card-info .name {
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.brand-card-info .tagline {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.brand-card-colors {
  display: flex;
  gap: 4px;
}

.brand-card-colors .color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.brand-card-actions {
  display: flex;
  gap: 8px;
}

.brand-card-actions button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.brand-card-actions .edit-btn {
  background: var(--gray-200);
  color: var(--gray-600);
}

.brand-card-actions .edit-btn:hover {
  background: var(--primary);
  color: var(--white);
}

.brand-card-actions .delete-btn {
  background: var(--gray-200);
  color: var(--gray-600);
}

.brand-card-actions .delete-btn:hover {
  background: var(--danger);
  color: var(--white);
}

/* Brand Form */
.brand-form-section {
  background: var(--white);
  border-radius: 16px;
  padding: 25px;
  box-shadow: var(--shadow);
}

.brand-form-section h3 {
  font-size: 1.2rem;
  color: var(--gray-700);
  margin-bottom: 20px;
}

.brand-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.color-input {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-input input[type="color"] {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}

.color-input input[type="text"] {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.95rem;
}

.color-input input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

.upload-area.small {
  padding: 20px;
}

.upload-area.small .upload-icon {
  font-size: 1.8rem;
}

.logo-preview {
  position: relative;
  display: inline-block;
  margin-top: 10px;
}

.logo-preview img {
  max-width: 120px;
  max-height: 80px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--gray-100);
  padding: 10px;
}

.brand-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.brand-form-actions button {
  flex: 1;
}

/* Responsive */
@media (max-width: 900px) {
  .brands-layout {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .header {
    flex-direction: column;
    text-align: center;
  }

  .header-content {
    text-align: center;
  }
}

/* Fix upload area display */
.upload-area.small {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

#logo-upload-area {
  display: flex;
}
