/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 16px; color: #1a1a2e; background: #f5f5f7; }
a { color: #C8102E; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Container ── */
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

/* ── Navbar ── */
.navbar { background: #1a1a2e; color: #fff; padding: 0 16px; }
.navbar-inner { max-width: 960px; margin: 0 auto; display: flex; align-items: center; height: 56px; gap: 24px; }
.navbar-brand { font-weight: 700; font-size: 18px; color: #C8102E; }
.navbar-brand:hover { text-decoration: none; }
.navbar-links { display: flex; gap: 16px; }
.navbar-links a { color: #ccc; font-size: 14px; }
.navbar-links a:hover { color: #fff; text-decoration: none; }
.navbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.navbar-user { font-size: 13px; color: #aaa; }
.btn-logout { background: none; border: 1px solid #555; color: #ccc; padding: 4px 12px; border-radius: 4px; font-size: 13px; cursor: pointer; }
.btn-logout:hover { border-color: #C8102E; color: #fff; }

/* ── Flash ── */
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash-notice { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.flash-alert { background: #fbe9e7; color: #c62828; border: 1px solid #ffccbc; }

/* ── Auth pages ── */
.auth-wrapper { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.auth-card { background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); padding: 40px; width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 24px; margin-bottom: 4px; text-align: center; }
.auth-card .subtitle { font-size: 14px; color: #888; text-align: center; margin-bottom: 24px; }
.auth-card .brand { font-size: 16px; font-weight: 700; color: #C8102E; text-align: center; display: block; margin-bottom: 16px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #333; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 15px;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: #C8102E; box-shadow: 0 0 0 2px rgba(200,16,46,0.1);
}
.form-errors { background: #fbe9e7; border: 1px solid #ffccbc; border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; color: #c62828; }
.form-errors ul { margin: 4px 0 0 16px; }

/* ── Buttons ── */
.btn { display: inline-block; padding: 10px 20px; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; border: none; text-align: center; transition: background 0.15s; }
.btn-primary { background: #C8102E; color: #fff; width: 100%; }
.btn-primary:hover { background: #a00d24; text-decoration: none; }
.btn-secondary { background: #eee; color: #333; }
.btn-secondary:hover { background: #ddd; }

/* ── Links under forms ── */
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; color: #888; }
.auth-links a { color: #C8102E; }

/* ── Visualizer ── */
.visualizer h1 { margin-bottom: 24px; }
.viz-section { background: #fff; border-radius: 10px; padding: 24px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.viz-section h2 { font-size: 16px; color: #666; margin-bottom: 16px; }
.hidden { display: none !important; }

/* Upload zone */
.upload-zone { border: 2px dashed #ddd; border-radius: 10px; padding: 40px 20px; text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.upload-zone:hover, .upload-zone.dragover { border-color: #C8102E; background: #fef2f2; }
.upload-zone.has-image { border-style: solid; border-color: #ccc; padding: 12px; }
.upload-placeholder { color: #999; }
.upload-placeholder p { font-size: 15px; margin: 12px 0 4px; font-weight: 600; color: #333; }
.upload-placeholder span { font-size: 12px; }
.upload-preview { max-width: 100%; max-height: 400px; border-radius: 8px; display: block; margin: 0 auto; }

/* Products grid */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.product-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; border: 2px solid #eee; border-radius: 10px; background: #fff; cursor: pointer; transition: all 0.15s; }
.product-card:hover { border-color: #ccc; background: #fafafa; }
.product-card.selected { border-color: #C8102E; background: #fef2f2; }
.product-icon { width: 36px; height: 36px; }
.product-icon svg { width: 100%; height: 100%; }
.product-name { font-size: 11px; font-weight: 600; text-align: center; line-height: 1.2; color: #333; }

/* Variants */
.variant-group { margin-bottom: 16px; }
.variant-group h3 { font-size: 13px; font-weight: 600; color: #666; margin-bottom: 8px; }
.variants-row { display: flex; flex-wrap: wrap; gap: 8px; }
.variant-chip { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 2px solid #eee; border-radius: 20px; background: #fff; cursor: pointer; transition: all 0.15s; font-size: 13px; }
.variant-chip:hover { border-color: #ccc; }
.variant-chip.selected { border-color: #C8102E; background: #fef2f2; }
.variant-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); flex-shrink: 0; }
.variant-label { color: #333; }

/* Actions */
.viz-actions { margin-top: 8px; }
.btn-generate { font-size: 16px; padding: 14px 24px; }
.btn-generate:disabled { background: #ccc; cursor: not-allowed; }

/* ── Generation result ── */
.generation-page { max-width: 700px; margin: 0 auto; }
.generation-header { margin-bottom: 20px; }
.generation-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.badge { display: inline-block; background: #f0f0f0; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; color: #333; }
.generation-date { font-size: 13px; color: #888; }

/* Loading */
.generation-loading { text-align: center; padding: 60px 20px; }
.generation-loading p { font-size: 16px; font-weight: 600; margin-top: 16px; }
.generation-loading span { font-size: 13px; color: #888; }
.spinner { width: 40px; height: 40px; border: 3px solid #eee; border-top-color: #C8102E; border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Compare slider */
.compare-container { position: relative; overflow: hidden; border-radius: 10px; user-select: none; -webkit-user-select: none; }
.compare-container img { display: block; width: 100%; }
.compare-before { position: relative; z-index: 1; }
.compare-after { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; clip-path: inset(0 0 0 50%); }
.compare-slider { position: absolute; top: 0; left: 50%; width: 4px; height: 100%; z-index: 3; cursor: ew-resize; transform: translateX(-50%); }
.compare-slider-line { width: 2px; height: 100%; background: #fff; margin: 0 auto; box-shadow: 0 0 4px rgba(0,0,0,0.3); }
.compare-slider-button { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; background: #C8102E; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.compare-labels { display: flex; justify-content: space-between; padding: 8px 4px 0; font-size: 13px; color: #888; font-weight: 600; }

/* Timing & download */
.generation-timing { text-align: center; font-size: 13px; color: #888; margin-top: 12px; }
.generation-download { text-align: center; margin-top: 16px; }
.generation-download .btn { width: auto; }
.generation-actions { display: flex; gap: 12px; margin-top: 24px; justify-content: center; }
.generation-actions .btn { width: auto; }

/* Error */
.generation-error { text-align: center; padding: 40px 20px; }
.generation-error p { font-size: 16px; font-weight: 600; color: #c62828; margin-bottom: 8px; }
.error-detail { font-size: 13px; color: #888; display: block; margin-bottom: 16px; }
.generation-error .btn { width: auto; }

/* ── History page ── */
.history-page { }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.history-header h1 { margin: 0; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* Filters */
.history-filters { background: #fff; border-radius: 10px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.filters-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filter-group { flex: 1; min-width: 140px; }
.filter-input, .filter-select { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }
.filter-input:focus, .filter-select:focus { outline: none; border-color: #C8102E; }
.filter-date { min-width: 120px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.btn-link { font-size: 13px; color: #C8102E; background: none; border: none; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }

/* Results count */
.history-count { font-size: 13px; color: #888; margin-bottom: 12px; }

/* Generations list (history) */
.generations-list { display: grid; gap: 12px; }
.generation-card { display: flex; gap: 16px; background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); text-decoration: none; color: inherit; transition: box-shadow 0.15s; }
.generation-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.1); text-decoration: none; }
.generation-card-images { flex-shrink: 0; }
.generation-card-thumb { width: 90px; height: 90px; border-radius: 8px; object-fit: cover; display: block; }
.generation-card-placeholder { background: #f5f5f7; display: flex; align-items: center; justify-content: center; }
.generation-card-body { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.generation-card-top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.generation-card-products { font-size: 14px; margin-bottom: 2px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.generation-card-client { font-size: 13px; color: #555; margin-top: 2px; }
.generation-card-meta { font-size: 12px; color: #888; margin-top: 4px; display: flex; gap: 4px; }
.generation-card-status { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 8px; height: fit-content; white-space: nowrap; }
.status-completed { background: #e8f5e9; color: #2e7d32; }
.status-pending, .status-processing { background: #fff3e0; color: #e65100; }
.status-failed { background: #fbe9e7; color: #c62828; }

/* Empty state */
.history-empty { text-align: center; padding: 60px 20px; color: #888; }
.history-empty p { font-size: 15px; margin: 12px 0 16px; }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 24px; padding: 16px 0; }
.pagination-link { font-size: 14px; color: #C8102E; font-weight: 600; }
.pagination-link:hover { text-decoration: underline; }
.pagination-info { font-size: 13px; color: #888; }

/* Generation show header */
.generation-header-top { display: flex; justify-content: space-between; align-items: center; }
.generation-client-info { margin-top: 12px; background: #f9f9f9; padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.generation-client-info p { margin-bottom: 4px; }
.generation-client-info p:last-child { margin-bottom: 0; }

/* Delete button */
.btn-danger { background: #fff; color: #c62828; border: 1px solid #e0e0e0; }
.btn-danger:hover { background: #fbe9e7; border-color: #c62828; }

/* Form row */
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-input:focus { outline: none; border-color: #C8102E; box-shadow: 0 0 0 2px rgba(200,16,46,0.1); }
.form-textarea { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; font-family: inherit; min-height: 100px; resize: vertical; line-height: 1.5; }
.form-textarea:focus { outline: none; border-color: #C8102E; box-shadow: 0 0 0 2px rgba(200,16,46,0.1); }
.form-textarea::placeholder { color: #999; }
.variants-label { font-size: 13px; font-weight: 600; color: #666; margin: 16px 0 8px; }
.optional-label { font-size: 12px; font-weight: 400; color: #999; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .auth-card { padding: 24px 20px; margin: 16px; }
  .navbar-user { display: none; }
  .products-grid { grid-template-columns: repeat(3, 1fr); }
  .generation-card { flex-direction: column; }
  .generation-card-thumb { width: 100%; height: 160px; }
  .filters-row { flex-direction: column; }
  .filter-group { min-width: 100%; }
  .history-header { flex-direction: column; gap: 12px; align-items: stretch; }
  .form-row { flex-direction: column; }
  .generation-header-top { flex-direction: column; gap: 8px; }
}
