/* ═══════════════════════════════════════════════════════════════
   RESONANCE STUDIO — studio-panels.css
   Advanced collapsible panel styles, paint tools, filter grid,
   layer management, upgraded sidebar layout
═══════════════════════════════════════════════════════════════ */

/* ── COLLAPSIBLE SECTION SYSTEM ─────────────────────────────── */
.sp-panel { padding: 8px 12px; }

.sp-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin: 0 -12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.06);
  transition: background .15s;
  user-select: none;
}
.sp-section-header:hover { background: rgba(255,78,205,.04); }
.sp-section-header.sp-open { border-bottom-color: rgba(255,78,205,.12); }

.sp-section-title {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  letter-spacing: .3px;
}

.sp-section-arrow {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  transition: transform .2s;
}
.sp-section-header.sp-open .sp-section-arrow { transform: rotate(0deg); }

.sp-section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .2s ease;
  padding: 0 0;
}
.sp-section-body.sp-open {
  max-height: 2000px;
  padding: 10px 0;
  overflow-y: auto;
}

/* ── SUBSECTION TITLES ──────────────────────────────────────── */
.sp-subsection-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.sp-hint {
  font-size: 11px;
  color: rgba(255,255,255,.35);
  margin: 0 0 8px;
  line-height: 1.4;
}

/* ── SEARCH INPUT ───────────────────────────────────────────── */
.sp-search-input {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.sp-search-input:focus { border-color: #ff4ecd; }

/* ── CATEGORY TABS ──────────────────────────────────────────── */
.sp-cat-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.sp-cat-btn {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.12);
  background: transparent;
  color: rgba(255,255,255,.5);
  font-family: inherit;
  transition: all .15s;
}
.sp-cat-btn.active, .sp-cat-btn:hover {
  background: rgba(255,78,205,.12);
  border-color: rgba(255,78,205,.4);
  color: #ff4ecd;
}

/* ── TEXT ADD BUTTONS ───────────────────────────────────────── */
.sp-text-add {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}
.sp-add-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all .15s;
}
.sp-add-btn:hover {
  border-color: rgba(255,78,205,.3);
  background: rgba(255,78,205,.06);
}

/* ── EFFECTS GRID ───────────────────────────────────────────── */
.sp-effects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}
.sp-effect-btn {
  padding: 8px 4px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.03);
  color: rgba(255,255,255,.7);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: all .15s;
}
.sp-effect-btn:hover {
  border-color: rgba(255,78,205,.4);
  background: rgba(255,78,205,.08);
  color: #ff4ecd;
}

/* ── SHAPES GRID ────────────────────────────────────────────── */
.sp-shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}
.sp-shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.08);
  background: transparent;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.sp-shape-btn:hover {
  border-color: rgba(255,78,205,.4);
  background: rgba(255,78,205,.06);
}
.sp-shape-icon { font-size: 18px; }
.sp-shape-label { font-size: 9px; font-weight: 600; }

.sp-line-row {
  display: flex; gap: 5px; margin-bottom: 10px;
}
.sp-line-btn {
  flex: 1;
  padding: 7px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.1);
  background: transparent;
  color: rgba(255,255,255,.6);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.sp-line-btn:hover { border-color: rgba(255,78,205,.3); color: #ff4ecd; }

/* ── PAINT TOOLS ────────────────────────────────────────────── */
.sp-paint-tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 5px;
  margin-bottom: 12px;
}
.sp-paint-btn {
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.03);
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: all .15s;
}
.sp-paint-btn:hover { border-color: rgba(255,78,205,.3); background: rgba(255,78,205,.06); }
.sp-paint-btn.active { border-color: #ff4ecd; background: rgba(255,78,205,.15); color: #ff4ecd; }
.sp-paint-exit { border-color: rgba(239,68,68,.3); color: rgba(239,68,68,.8); }
.sp-paint-exit:hover { background: rgba(239,68,68,.1); border-color: #ef4444; }

/* ── BRUSH SETTINGS ─────────────────────────────────────────── */
.sp-brush-settings { margin-bottom: 12px; }
.sp-slider-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.5);
  margin-bottom: 3px;
  display: block;
}
.sp-slider {
  width: 100%;
  height: 4px;
  accent-color: #ff4ecd;
  margin-bottom: 10px;
  cursor: pointer;
}
.sp-color-row {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.sp-color-pick {
  width: 28px; height: 28px;
  border: none; border-radius: 6px;
  cursor: pointer; padding: 0;
}
.sp-color-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.15);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.sp-color-swatch:hover { border-color: #fff; transform: scale(1.15); }

/* ── BACKGROUND PANEL ───────────────────────────────────────── */
.sp-bg-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sp-bg-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,.12);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  position: relative;
}
.sp-bg-swatch:hover { border-color: #ff4ecd; transform: scale(1.1); }
.sp-bg-custom {
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; overflow: hidden;
}
.sp-gradient-row {
  display: flex; align-items: center; gap: 6px;
}
.sp-gradient-row span { color: rgba(255,255,255,.4); font-size: 12px; }
.sp-small-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,78,205,.08);
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.sp-small-btn:hover { border-color: #ff4ecd; color: #ff4ecd; }

/* ── FILTER PRESETS ─────────────────────────────────────────── */
.sp-filter-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 5px;
}
.sp-filter-thumb {
  padding: 10px 4px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  color: rgba(255,255,255,.6);
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  font-family: inherit;
}
.sp-filter-thumb:hover { border-color: rgba(255,78,205,.3); background: rgba(255,78,205,.06); }
.sp-filter-thumb.active { border-color: #ff4ecd; background: rgba(255,78,205,.12); color: #ff4ecd; }
.sp-filter-name { display: block; margin-top: 2px; }

/* ── FILTER ADJUSTMENTS ─────────────────────────────────────── */
.sp-adj-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.sp-adj-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.5);
  min-width: 62px;
  flex-shrink: 0;
}
.sp-adj-row .sp-slider { margin-bottom: 0; flex: 1; }

/* ── LAYERS PANEL ───────────────────────────────────────────── */
.sp-layers-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 4px;
}
.sp-layers-btn {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.1);
  background: transparent;
  color: rgba(255,255,255,.5);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.sp-layers-btn:hover { border-color: rgba(255,78,205,.3); color: #ff4ecd; }

.sp-layers-list { max-height: 400px; overflow-y: auto; }
.sp-layers-empty {
  padding: 20px;
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,.3);
}

.sp-layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .12s;
}
.sp-layer-item:hover { background: rgba(255,255,255,.04); }
.sp-layer-item.active { background: rgba(255,78,205,.08); border-color: rgba(255,78,205,.2); }

.sp-layer-icon {
  width: 20px; text-align: center;
  font-size: 13px; flex-shrink: 0;
}
.sp-layer-name {
  flex: 1; min-width: 0;
  background: transparent;
  border: none; border-bottom: 1px solid transparent;
  color: rgba(255,255,255,.75);
  font-size: 11px; font-weight: 500;
  font-family: inherit; outline: none;
  padding: 2px 0;
  text-overflow: ellipsis; overflow: hidden;
}
.sp-layer-name:focus { border-bottom-color: #ff4ecd; color: #fff; }
.sp-layer-action {
  background: transparent; border: none;
  font-size: 11px; cursor: pointer;
  padding: 2px 4px; border-radius: 3px;
  transition: background .12s;
  line-height: 1;
}
.sp-layer-action:hover { background: rgba(255,255,255,.08); }
.sp-layer-del:hover { background: rgba(239,68,68,.15); }

/* ── CLIPART & WRITER GRIDS ─────────────────────────────────── */
.sp-clipart-grid, .sp-writer-grid, .sp-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 5px;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 6px;
}

/* ── FONT LIST (reuses existing styling concept) ────────────── */
.sp-font-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 6px;
  margin-top: 4px;
}

/* ── MOBILE RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 767px) {
  .sp-panel { padding: 6px 10px; }
  .sp-section-header { padding: 8px 10px; margin: 0 -10px; }
  .sp-shape-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
  .sp-paint-tools { grid-template-columns: repeat(3, 1fr); }
  .sp-filter-presets { grid-template-columns: repeat(3, 1fr); }
  .sp-effects-grid { grid-template-columns: repeat(3, 1fr); }
  .sp-layers-list { max-height: 260px; }
}
