/* Main dashboard area right of the sidebar */

.main-shell {
  margin-left: 260px;
  min-height: 100vh;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
}

@media (max-width: 767px) {
  .main-shell { margin-left: 0; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid #e8e8ec;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* Studio two-column layout (kept from previous iteration) */

.studio-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 900px) {
  .studio-grid { grid-template-columns: 1fr; }
}

.picker-card {
  background: #ffffff;
  border: 1px solid #e8e8ec;
  border-radius: 16px;
  padding: 1.25rem;
}

.controls-card {
  background: #ffffff;
  border: 1px solid #e8e8ec;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(20, 20, 30, 0.06);
}

.controls-card label { font-size: 0.85rem; }

.controls-card input[type="text"],
.controls-card input[type="number"] {
  height: 40px;
  width: 100%;
  padding: 0 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  box-sizing: border-box;
  margin: 0.25rem 0 0.75rem;
}

.dropzone {
  border: none;
  background: #f4f4f7;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  margin: 0.9rem 0;
  transition: background 0.2s ease;
}
.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragging {
  background: #ede9fe;
  outline: none;
}
.dropzone p { margin: 0.15rem 0; font-size: 0.85rem; }
.dropzone svg { width: 24px; height: 24px; }

.segmented {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 10px;
  overflow: hidden;
  height: 40px;
  margin: 0.75rem 0;
}
.seg-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease;
}
.seg-option + .seg-option { border-left: 1px solid #ddd; }
.seg-option:has(input:checked) {
  background: #7c3aed;
  color: #fff;
  font-weight: 600;
}
.seg-option input { position: absolute; opacity: 0; }

.advanced summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.recolor-btn {
  display: block;
  width: 100%;
  height: 48px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 0.75rem;
  transition: box-shadow 0.2s ease;
}
.recolor-btn:hover { box-shadow: 0 0 20px rgba(124, 58, 237, 0.45); }

/* History grid */

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.filters-bar select,
.filters-bar .filter-btn {
  height: 36px;
  padding: 0 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
}

.filters-bar .filter-btn.active {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.run-tile {
  background: #fff;
  border: 1px solid #e8e8ec;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.run-tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.run-tile .tile-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.run-tile .tile-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.run-tile .tile-meta {
  font-size: 0.78rem;
  color: #77777f;
}

.run-tile .tile-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.tile-actions a,
.tile-actions button {
  flex: 1;
  text-align: center;
  padding: 0.45rem 0;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
}

.tile-actions .rerun {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .recolor-btn, .seg-option, .dropzone, .nav-item { transition: none; }
}

.app-footer {
  padding: 0.9rem 1.5rem;
  border-top: 1px solid #e8e8ec;
  color: #666666;
  font-size: 0.8rem;
  background: #ffffff;
}

.controls-card .sound-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #1a1a1a;
  font-size: 0.9rem;
  margin: 0.25rem 0 0.75rem;
}

/* Unified studio card */
.studio-card {
  background: #ffffff;
  border: 1px solid #e8e8ec;
  border-radius: 16px;
  padding: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
}
.studio-card .picker-card,
.studio-card .controls-card {
  border: none;
  box-shadow: none;
  padding: 0;
}
.studio-card .studio-grid { max-width: none; margin: 0; gap: 2rem; }
.studio-card .picker-card { flex: 1.85; }
.studio-card .controls-card { flex: 1; min-width: 300px; max-width: 360px; }
@media (min-width: 901px) {
  .studio-card .studio-grid { grid-template-columns: 1.85fr 1fr; }
}

/* White modern inputs */
.controls-card input[type="text"],
.controls-card input[type="number"] {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #1f2937;
  border-radius: 8px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.controls-card input[type="text"]:focus,
.controls-card input[type="number"]:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.35);
}
.controls-card ::placeholder { color: #9ca3af; opacity: 1; }

/* Result stage (in-place overlay in the picker column) */
.result-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1a1a;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-stage .stage-original {
  max-width: 100%;
  max-height: 420px;
  filter: blur(2px) saturate(0.6);
  opacity: 0.7;
}
.result-stage.is-revealed .stage-original { display: none; }
.result-stage .stage-result {
  max-width: 100%;
  max-height: 420px;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.5s ease 0.25s, transform 0.6s cubic-bezier(0.22,1,0.36,1) 0.25s;
}
.result-stage .stage-result.shown { opacity: 1; transform: scale(1); }
.result-stage .premium-overlay { border-radius: 12px; }

.stage-actions {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  z-index: 40;
}
.stage-btn {
  padding: 0.6rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #1f2937;
}
.stage-btn.primary {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border: none;
  color: #ffffff;
}

/* 3-zone studio layout */
.studio-3zone {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  .studio-3zone { grid-template-columns: 1fr; }
}

/* Drop zone: focal center stage */
.dropzone {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 2px dashed #d1d5db;
  border-radius: 16px;
  background: #fafafa;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragging {
  border-color: #7c3aed;
  background: #f5f3ff;
  outline: none;
}
.dropzone p { margin: 0.25rem 0; font-size: 0.95rem; color: #374151; }
.dropzone.filled { border-style: solid; padding: 0.75rem; cursor: pointer; }
.dropzone .dz-preview {
  max-width: 100%;
  max-height: 420px;
  border-radius: 10px;
  object-fit: contain;
}
.dropzone .dz-filename { font-weight: 600; color: #1f2937; }
.dropzone.generating { border-style: solid; background: #1a1a1a; min-height: 500px; }
.dropzone.result { border-style: solid; background: #1a1a1a; min-height: 500px; position: relative; }
.dropzone .dz-result {
  max-width: 100%;
  max-height: 460px;
  border-radius: 10px;
  object-fit: contain;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.5s ease 0.25s, transform 0.6s cubic-bezier(0.22,1,0.36,1) 0.25s;
}
.dropzone .dz-result.shown { opacity: 1; transform: scale(1); }
.dropzone .premium-overlay { border-radius: 14px; }
.dropzone .gen-error { text-align: center; color: #fff; }

.stage-actions {
  position: absolute;
  bottom: 1rem;
  left: 0; right: 0;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  z-index: 40;
}
.stage-btn {
  padding: 0.6rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
}
.stage-btn.primary {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border: none;
  color: #ffffff;
}

/* Swatch active state: white ring + scale */
.swatch-btn.active {
  transform: scale(1.15);
  border-color: #ffffff;
  box-shadow: 0 0 0 3px #7c3aed, 0 4px 14px rgba(0,0,0,0.3);
}

/* Controls sidebar stack */
.controls-card { position: sticky; top: 80px; }

/* White clean inputs */
.controls-card input[type="text"],
.controls-card input[type="number"] {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #374151;
  height: 40px;
  border-radius: 8px;
  width: 100%;
  padding: 0 0.75rem;
  box-sizing: border-box;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.controls-card input:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.35);
}
.controls-card ::placeholder { color: #9ca3af; opacity: 1; }

/* Right-panel color section */
.color-section { margin: 0.75rem 0; }
.section-label { display: block; font-weight: 600; color: #1a1a1a; font-size: 0.9rem; margin-bottom: 0.5rem; }
.color-section .swatch-scroll {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c4c4cc transparent;
}
.color-section .swatch-scroll::-webkit-scrollbar { width: 5px; }
.color-section .swatch-scroll::-webkit-scrollbar-thumb { background: #c4c4cc; border-radius: 3px; }
.color-section .color-grid { grid-template-columns: repeat(7, 1fr); gap: 6px; }
.color-section .color-name { font-size: 0.85rem; margin-top: 0.4rem; min-height: 1.2em; }


/* Overlay containment: overlay is a child of .dropzone, clipped to it */
.dropzone { position: relative; overflow: hidden; }
.dropzone .premium-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
}
.dropzone .fx-canvas {
  position: absolute;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
}
.stage-actions { z-index: 40; }

/* Perfect-circle swatches: fixed dims, no deformation, no layout shift */
.color-section .color-grid {
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px;
}
.swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
  padding: 0;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.swatch:hover { transform: scale(1.08); }

/* Selection: outline ring (takes no layout space) + centered checkmark */
.swatch.active {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
  transform: scale(1.1);
  z-index: 10;
  position: relative;
}
.swatch {
  display: flex;
  align-items: center;
  justify-content: center;
}
.swatch svg { pointer-events: none; }
.swatch:not(.active) svg { display: none; }

@media (prefers-reduced-motion: reduce) {
  .swatch { transition: none; }
}

/* Result image stacks above the dark stage background */
.dropzone.result .dz-result {
  position: relative;
  z-index: 20;
}
/* Once result state is reached, the loading overlay is gone with the innerHTML swap;
   belt-and-suspenders: never let a stray overlay cover the result image */
.dropzone.result .premium-overlay {
  display: none !important;
}

/* Bottom two-button row: Start Over (left) + Download PNG (right) */
.stage-actions {
  display: flex;
  gap: 1rem;
  padding: 0 1rem;
}
.stage-actions[hidden] { display: none; }
.stage-actions .stage-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border-radius: 10px;
  text-align: center;
}
.stage-actions .stage-btn.primary {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border: none;
  color: #ffffff;
}
