/* ─── HELMUR Catalog Dashboard ─────────────────────────────────────────────── */
:root {
  --bg: #f5f5f0;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #888;
  --border: #e0ddd5;
  --accent: #8b7355;
  --accent-hover: #6b5a45;
  --radius: 6px;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text);
  text-decoration: none;
}
.topbar-subtitle {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-logout, .btn-refresh {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  transition: all .15s;
}
.btn-logout:hover, .btn-refresh:hover {
  background: var(--bg);
  border-color: var(--accent);
}

/* ─── Login ───────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--card);
  padding: 48px 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: center;
  max-width: 380px;
  width: 90%;
}
.login-logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--accent);
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 2px;
  margin-bottom: 32px;
}
.login-error {
  color: #c0392b;
  font-size: 14px;
  margin-bottom: 16px;
}
.login-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s;
}
.login-form input:focus { border-color: var(--accent); }
.login-form button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}
.login-form button:hover { background: var(--accent-hover); }

/* ─── Gender Selector ─────────────────────────────────────────────────────── */
.gender-selector {
  padding: 48px 24px;
  max-width: 900px;
  margin: 0 auto;
}
.page-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 32px;
  color: var(--text);
}
.gender-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.gender-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all .2s;
  cursor: pointer;
}
.gender-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.gender-card.donna { background: linear-gradient(135deg, #faf5f0, #f0e8e0); }
.gender-card.uomo { background: linear-gradient(135deg, #f0f2f5, #e0e5ea); }
.gender-label {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 4px;
  margin-bottom: 8px;
}
.gender-count {
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 600px) {
  .gender-cards { grid-template-columns: 1fr; }
  .gender-card { padding: 40px 20px; }
  .gender-label { font-size: 26px; }
}

/* ─── Catalog Grid ────────────────────────────────────────────────────────── */
.catalog-page { padding: 24px; max-width: 1400px; margin: 0 auto; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.product-preview {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg);
}
.product-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.no-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
}
.product-info {
  padding: 12px 14px;
}
.product-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.product-meta {
  font-size: 12px;
  color: var(--muted);
}

/* ─── Product Detail ───────────────────────────────────────────────────────── */
.product-page {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 12px;
}
.product-ref-section, .color-refs-section {
  margin-bottom: 32px;
}
.product-ref-img {
  max-width: 400px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.product-ref-img img {
  width: 100%;
  display: block;
}
.color-refs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.color-ref-item {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.color-ref-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── Matrix Table ────────────────────────────────────────────────────────── */
.matrix-section { margin-bottom: 32px; }
.matrix-table {
  overflow-x: auto;
}
.matrix-table table {
  border-collapse: separate;
  border-spacing: 6px;
  width: 100%;
}
.matrix-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 8px 12px;
  text-align: center;
  white-space: nowrap;
}
.matrix-table th.corner-cell {
  text-align: left;
  font-size: 11px;
  min-width: 140px;
}
.matrix-table td {
  padding: 0;
  text-align: center;
}
.matrix-table td.color-label {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  white-space: nowrap;
  color: var(--text);
  min-width: 140px;
}
.matrix-cell { width: 200px; }
/* ─── Cell wrap & actions ─────────────────────────────────────────────────── */
.cell-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}
.cell-img {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  aspect-ratio: 3/4;
  transition: border-color .15s, box-shadow .15s;
}
.cell-img:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.cell-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cell-img.approved {
  border-color: #2e7d32;
  border-width: 2px;
  box-shadow: 0 0 0 2px rgba(46,125,50,.2);
}
.cell-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  justify-content: center;
}
.btn-thumb, .btn-regen {
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  transition: all .15s;
  line-height: 1;
}
.btn-thumb:hover { background: #e8f5e9; border-color: #2e7d32; }
.btn-thumb.active { background: #2e7d32; color: white; border-color: #2e7d32; font-weight: bold; }
.btn-regen:hover { background: #fff3e0; border-color: #e65100; }
.cell-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3/4;
  color: var(--muted);
  font-size: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ─── Lightbox (grande) ────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none !important; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.92);
}
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  position: relative;
  z-index: 1;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 24px;
  z-index: 2;
  background: rgba(255,255,255,.15);
  border: none;
  color: white;
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 14px;
  border-radius: 50%;
  opacity: .8;
  transition: opacity .15s, background .15s;
}
.lightbox-close:hover { opacity: 1; background: rgba(255,255,255,.25); }

/* ─── Regeneration panel ───────────────────────────────────────────────────── */
.regen-overlay, .comparison-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.regen-overlay[hidden], .comparison-overlay[hidden] { display: none !important; }
.regen-panel, .comparison-panel {
  background: var(--card);
  border-radius: 12px;
  max-width: 1100px;
  width: 100%;
  max-height: 95vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.regen-header, .comparison-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.regen-header h2, .comparison-header h2 {
  font-size: 18px;
  font-weight: 600;
}
.regen-close, .comparison-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.regen-close:hover, .comparison-close:hover { color: var(--text); }
.regen-body { padding: 24px; }
.regen-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.regen-col { text-align: center; }
.regen-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}
.regen-col img {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: contain;
}
.regen-ref-info {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.regen-info {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
}
.regen-notes-section {
  margin-bottom: 20px;
}
.regen-notes-section label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.regen-notes-section textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.regen-notes-section textarea:focus { border-color: var(--accent); }
.btn-primary {
  padding: 12px 32px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* Regen progress */
.regen-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 16px;
  background: #f0f7ff;
  border-radius: var(--radius);
  font-size: 13px;
  color: #1565c0;
}
.regen-progress[hidden] { display: none !important; }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #90caf9;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Comparison panel ────────────────────────────────────────────────────── */
.comparison-body { padding: 24px; }
.comparison-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.comparison-col { text-align: center; }
.comparison-label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  display: inline-block;
}
.comparison-col:first-child .comparison-label { background: #ffebee; color: #c62828; }
.comparison-col:last-child .comparison-label { background: #e8f5e9; color: #2e7d32; }
.comparison-col img {
  max-width: 100%;
  max-height: 500px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: contain;
}
.comparison-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.btn-reject {
  padding: 12px 28px;
  background: #f5f5f0;
  color: #c62828;
  border: 1px solid #c62828;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: all .15s;
}
.btn-reject:hover { background: #ffebee; }
.btn-accept {
  padding: 12px 28px;
  background: #2e7d32;
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}
.btn-accept:hover { background: #1b5e20; }

/* ─── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .matrix-table table { min-width: 600px; }
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .catalog-page { padding: 16px; }
  .product-page { padding: 16px; }
  .color-ref-item { width: 80px; height: 80px; }
  .topbar { padding: 12px 16px; }
  .topbar-subtitle { display: none; }
  .regen-images, .comparison-images { grid-template-columns: 1fr; }
  .regen-panel, .comparison-panel { max-width: 95vw; }
}
