/* ── Page ─────────────────────────────────────────────────────── */
.bead-page { padding-bottom: 42px; }

.bead-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 4px 18px;
  flex-wrap: wrap;
}

/* Generator page: three-column grid — title | tabs(centered) | subtitle */
.bead-hero-generator {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.bead-hero-generator h1 {
  margin: 0;
  grid-column: 1;
  /* Inherits font from .bead-hero h1 */
}

.bead-hero-generator .bead-tab-bar {
  grid-column: 2;
}

.bead-hero-generator .hero-copy {
  grid-column: 3;
  margin: 0;
  font-size: 15px;
  color: #546274;
  text-align: right;
}

.bead-hero h1 {
  margin: 0;
  color: #18202b;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
}

.hero-copy {
  max-width: 620px;
  margin: 12px 0 0;
  color: #546274;
  font-size: 15px;
  line-height: 1.7;
}

/* ── Workspace grid ───────────────────────────────────────────── */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(230px, 0.68fr) minmax(0, 1.36fr) 300px;
  gap: 18px;
  align-items: stretch;
}

.workspace-grid > * {
  min-height: 0;
}

/* ── Panels ───────────────────────────────────────────────────── */
.panel {
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(172,189,209,0.34);
  border-radius: 8px;
  box-shadow: 0 26px 58px rgba(29,62,98,0.075);
}

.upload-panel,
.preview-panel,
.controls-panel {
  padding: 18px;
}

.upload-panel {
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin: 0;
  color: #202a36;
  font-size: 17px;
  font-weight: 800;
}

.panel-title .material-symbols-outlined { color: #1677ff; }

/* ── Upload / Drop zone ───────────────────────────────────────── */
.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 200px;
  overflow: hidden;
  border: 1.5px dashed rgba(83,106,134,0.32);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.90), rgba(242,247,252,0.92)),
    linear-gradient(150deg, rgba(22,119,255,0.08), transparent 42%),
    linear-gradient(330deg, rgba(224,151,73,0.12), transparent 44%);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: rgba(22,119,255,0.75);
  background: #f7fbff;
}

.drop-zone input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

#sourcePreview {
  display: none;
  width: 100%; height: 100%;
  max-height: 280px;
  object-fit: contain;
  padding: 14px;
}

.drop-zone.has-image #sourcePreview { display: block; }

.upload-hint {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  color: #637184;
  text-align: center;
  padding: 18px;
  z-index: 2;
  pointer-events: none;
}

.drop-zone.has-image .upload-hint {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  flex-direction: row;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(17,24,39,0.58));
  border-radius: 0 0 7px 7px;
}

.drop-zone.has-image .upload-hint .material-symbols-outlined {
  width: auto; height: auto; padding: 0; border-radius: 0;
  color: rgba(255,255,255,0.85); background: transparent; box-shadow: none;
  font-size: 18px;
}

.drop-zone.has-image .upload-hint strong { color: #fff; font-size: 13px; }
.drop-zone.has-image .upload-hint small { display: none; }

.upload-hint .material-symbols-outlined {
  display: grid;
  place-items: center;
  width: 58px; height: 58px;
  border-radius: 18px;
  color: #1677ff;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 14px 28px rgba(22,119,255,0.12);
  font-size: 36px;
}

.upload-hint strong { color: #263342; font-size: 16px; }
.upload-hint small { font-size: 12px; }

.upload-tip {
  margin: 8px 0 0;
  color: #8b919a;
  font-size: 12px;
  text-align: center;
}

.file-row {
  display: none;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  margin-top: 12px;
  color: #5b697b;
  font-size: 13px;
}

.file-row.visible { display: flex; }

#fileName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 44px);
}

.file-row button {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 8px;
  color: #69798d;
  background: #eef3f8;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
}

.file-row button:hover { background: #fde8e8; color: #ef4444; }

/* ── Canvas / Preview ─────────────────────────────────────────── */
.canvas-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(18,34,50,0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(18,34,50,0.035) 1px, transparent 1px),
    linear-gradient(135deg, #f7f1e8, #eef4f7);
  background-size: 20px 20px, 20px 20px, auto;
}

#resultCanvas {
  display: none;
  max-width: 100% !important;
  max-height: 100% !important;
  filter: drop-shadow(0 12px 20px rgba(67,58,42,0.12));
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: #7b6f5f;
  font-weight: 700;
  pointer-events: none;
}

.empty-state .material-symbols-outlined { font-size: 44px; }
.empty-state.hidden { display: none; }

/* ── Controls panel ───────────────────────────────────────────── */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  color: #546274;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Segmented buttons */
.segmented-group {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: #eef1f5;
  border-radius: 8px;
  padding: 3px;
}

.segmented-btn {
  flex: 1;
  min-width: 0;
  padding: 6px 2px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-align: center;
}

.segmented-btn:hover { color: #334155; }
.segmented-btn.active {
  background: #fff;
  color: #1677ff;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#brandGroup .segmented-btn { font-size: 11px; padding: 5px 1px; }

/* Toggle rows */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f5f8fb;
  cursor: pointer;
  user-select: none;
}

.toggle-row span {
  color: #263342;
  font-size: 13px;
  font-weight: 600;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  border-radius: 999px;
  background: #cfd8e3;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(28,38,52,0.15);
  transition: transform 0.2s ease;
}

.toggle-row input:checked + .toggle-track {
  background: #1677ff;
  box-shadow: 0 0 0 3px rgba(22,119,255,0.1);
}

.toggle-row input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* Buttons */
.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(145deg, #1677ff, #0f62d9);
  box-shadow: 0 12px 26px rgba(22,119,255,0.24);
}

.primary-btn:not(:disabled):hover { transform: translateY(-1px); }

/* Split download button */
.download-btn-row {
  display: flex;
  gap: 0;
  position: relative;
}

.download-btn-main {
  width: auto;
  flex: 1;
  border-radius: 8px 0 0 8px;
}

.download-btn-more {
  width: 36px !important;
  min-width: 36px;
  flex-shrink: 0;
  border-radius: 0 8px 8px 0;
  border-left: 1px solid rgba(255,255,255,0.25);
  padding: 0;
}

.download-btn-more span {
  font-size: 20px;
  transition: transform 0.2s ease;
}

.download-btn-more.open span {
  transform: rotate(180deg);
}

/* Download more popover */
.download-more-popover {
  display: none;
  position: absolute;
  z-index: 100;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
  padding: 4px;
}

.download-more-popover.visible {
  display: block;
}

.download-more-popover .toggle-row {
  border-radius: 6px;
}
.primary-btn:disabled { opacity: 0.48; cursor: not-allowed; transform: none; }

.secondary-btn {
  color: #334155;
  background: #e9eef4;
  font-size: 13px;
  min-height: 38px;
}

.secondary-btn:hover { background: #dde3eb; }

/* ── Stats ────────────────────────────────────────────────────── */
.stats-section.hidden { display: none; }

.stats-total {
  margin-left: auto;
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
}

.stats-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: #f2f4f7;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.stat-swatch {
  width: 14px; height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.stat-code { font-weight: 700; color: #374151; }
.stat-count { color: #9ca3af; font-weight: 500; }

/* ── Tablet ────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  }

  .controls-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .controls-panel .panel-title,
  .controls-panel .control-group:last-child {
    grid-column: 1 / -1;
  }

  .segmented-btn { font-size: 12px; padding: 8px 4px; }
  #brandGroup .segmented-btn { font-size: 11px; }
}

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .bead-page {
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-bottom: 18px;
  }

  .bead-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-top: 18px;
    padding-bottom: 12px;
  }

  .bead-hero h1 { font-size: 28px; }
  .hero-copy { margin-top: 8px; font-size: 13px; line-height: 1.55; }

  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .drop-zone { min-height: 200px; }
  .canvas-shell { min-height: 320px; }

  .upload-panel, .preview-panel, .controls-panel { padding: 16px 14px; }
  .panel-title { margin-bottom: 12px; }
  .panel-title h2 { font-size: 16px; }

  /* ── Mobile controls ─────────────────────────────────── */
  .controls-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .control-label {
    font-size: 12px;
    letter-spacing: 0.08em;
  }

  /* Segmented: bigger touch targets */
  .segmented-group {
    gap: 3px;
    border-radius: 10px;
    padding: 4px;
  }

  .segmented-btn {
    font-size: 14px;
    padding: 12px 6px;
    border-radius: 8px;
    min-height: 44px;
  }

  #brandGroup .segmented-btn {
    font-size: 13px;
    padding: 11px 4px;
  }

  /* Toggle rows: taller, bigger switch */
  .toggle-row {
    padding: 15px 13px;
    border-radius: 10px;
  }

  .toggle-row span { font-size: 15px; }

  .toggle-track {
    width: 50px; height: 28px;
    border-radius: 999px;
  }

  .toggle-track::after {
    top: 3px; left: 3px;
    width: 22px; height: 22px;
  }

  .toggle-row input:checked + .toggle-track::after {
    transform: translateX(22px);
  }

  /* Buttons */
  .primary-btn {
    min-height: 52px;
    font-size: 16px;
    border-radius: 10px;
    gap: 10px;
  }

  .download-btn-main {
    border-radius: 8px 0 0 8px;
  }

  .download-btn-more {
    border-radius: 0 8px 8px 0;
  }

  .secondary-btn {
    min-height: 46px;
    font-size: 14px;
    border-radius: 10px;
  }

  #resultCanvas { max-width: 100% !important; max-height: 360px; }

  .stat-chip {
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 6px;
    gap: 6px;
  }

  .stat-swatch { width: 16px; height: 16px; }

  .stats-total { font-size: 13px; }

  .upload-hint .material-symbols-outlined {
    width: 48px; height: 48px;
    font-size: 30px;
  }

  .upload-hint strong { font-size: 15px; }

  .bead-hero-generator {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .bead-hero-generator .bead-tab-bar {
    grid-column: 2;
    justify-self: end;
  }

  .bead-hero-generator .hero-copy {
    grid-column: 1 / -1;
    text-align: left;
  }

  .bead-tab {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
  }
}

/* ── Tab Navigation (shared with library page) ──────────────── */
.bead-tab-bar {
  display: inline-flex;
  background: #eef1f5;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.bead-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.bead-tab:hover {
  color: #475569;
  text-decoration: none;
}

.bead-tab.active {
  background: #fff;
  color: #1677ff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

@media (max-width: 700px) {
  .bead-hero-generator .bead-tab {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
  }
}

/* ── Trim background color badge & picker ─────────────────────────── */
.trim-bg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px 1px 2px;
  margin-left: 2px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  vertical-align: middle;
  line-height: 1;
}

.trim-bg-badge:hover {
  border-color: #1677ff;
  box-shadow: 0 0 0 2px rgba(22,119,255,0.1);
}

.trim-bg-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.trim-bg-code {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  letter-spacing: 0.02em;
}

.trim-bg-arrow {
  font-size: 16px;
  color: #94a3b8;
  margin-left: -2px;
}

.trim-bg-picker {
  display: none;
  position: absolute;
  z-index: 9999;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.14);
  padding: 8px;
  max-width: 560px;
  max-height: 360px;
  overflow-y: auto;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 3px;
}

.trim-bg-picker.visible {
  display: grid;
}

.trim-bg-swatch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 28px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 4px;
  cursor: pointer;
  padding: 0 2px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trim-bg-swatch-btn:hover {
  transform: scale(1.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border-color: #1677ff;
  z-index: 2;
  position: relative;
}

.trim-bg-swatch-btn.selected {
  border: 2px solid #1677ff;
  box-shadow: 0 0 0 2px rgba(22,119,255,0.25);
}

/* Mobile tweaks */
@media (max-width: 700px) {
  .trim-bg-picker {
    max-width: calc(100vw - 32px);
    left: 8px !important;
    right: 8px;
  }

  .trim-bg-swatch-btn {
    min-width: 34px;
    height: 24px;
    font-size: 8px;
  }
}
