/* ================================================================
   DESIGN STUDIO — Standalone Module CSS
   Drop this file into any Shadowslight app.
   Link: <link rel="stylesheet" href="design-studio.css">
   ================================================================ */

/* ================================================================
   EDIT TOOLBAR — fixed top bar, shown only in edit mode
   ================================================================ */
#ds-edit-toolbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 8900;
  height: 46px;
  background: #091510;
  border-bottom: 2px solid rgba(80,200,100,0.45);
  align-items: center; gap: 8px; padding: 0 14px;
  font-family: inherit;
}
#ds-edit-toolbar.active { display: flex; }

#ds-edit-page-label {
  font-size: 13px; font-weight: 700;
  color: #6eed9a; letter-spacing: 0.5px; white-space: nowrap;
}
#ds-edit-sel-name {
  font-size: 12px; color: rgba(140,255,140,0.6); white-space: nowrap;
}
.ds-tb-sep { width: 1px; height: 22px; background: rgba(255,255,255,0.1); flex-shrink: 0; }
.ds-tb-spacer { flex: 1; }

.ds-tb-btn {
  background: rgba(20,70,35,0.5);
  border: 1px solid rgba(80,200,100,0.3);
  color: #9eff9e; font-size: 12px; padding: 5px 11px;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  font-family: inherit; transition: background 0.15s;
}
.ds-tb-btn:hover { background: rgba(40,130,55,0.5); color: #fff; }

.ds-tb-btn.reset-btn {
  border-color: rgba(255,90,90,0.4);
  color: rgba(255,150,150,0.9);
  background: rgba(80,15,15,0.4);
}
.ds-tb-btn.reset-btn:hover { background: rgba(130,20,20,0.55); color: #fff; }

.ds-tb-btn.back-btn {
  border-color: rgba(255,215,0,0.35);
  color: rgba(255,215,0,0.8);
  background: transparent;
}
.ds-tb-btn.back-btn:hover { background: rgba(255,215,0,0.08); color: #ffd700; }

/* ================================================================
   EDITABLE ELEMENTS — outline and handles in edit mode
   ================================================================ */
body.ds-editing .ds-editable {
  outline: 1px dashed rgba(180,100,255,0.4);
  cursor: move;
}
body.ds-editing .ds-editable:hover {
  outline: 1px dashed rgba(180,100,255,0.75);
}
body.ds-editing .ds-editable.ds-selected {
  outline: 2px solid rgba(180,100,255,0.95);
  box-shadow: 0 0 0 3px rgba(180,100,255,0.18);
}

/* Element name label */
.ds-el-label {
  position: absolute; top: -20px; left: 0;
  background: rgba(35,0,70,0.9); color: rgba(200,155,255,0.95);
  font-size: 10px; padding: 2px 7px; border-radius: 3px 3px 0 0;
  white-space: nowrap; pointer-events: none; z-index: 10;
  font-family: sans-serif; font-weight: normal;
}

/* Corner resize handle */
.ds-el-resize {
  position: absolute; right: 0; bottom: 0;
  width: 16px; height: 16px; cursor: se-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(180,100,255,0.85) 50%);
  border-radius: 0 0 4px 0; z-index: 20;
}

/* ================================================================
   DESIGN STUDIO PANEL — slides in from left when element selected
   ================================================================ */
#ds-panel {
  display: none;
  position: fixed; top: 46px; left: 0;
  width: 284px;
  background: rgba(12,7,30,0.99);
  border-right: 1px solid rgba(180,100,255,0.4);
  border-bottom: 1px solid rgba(180,100,255,0.4);
  border-radius: 0 0 8px 0;
  z-index: 8800;
  overflow-y: auto; max-height: calc(100vh - 46px);
  font-family: inherit;
}
#ds-panel.open { display: block; }

/* Panel header */
.ds-hdr {
  background: #130b32;
  border-bottom: 1px solid rgba(180,100,255,0.2);
  padding: 9px 12px;
}
#ds-sel-name {
  font-size: 13px; font-weight: 700; color: #f0dcff; display: block;
}
#ds-pos-row {
  font-size: 11px; color: rgba(210,180,255,0.8);
  margin-top: 3px; font-family: monospace;
}

/* Panel sections */
.ds-sec {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(180,100,255,0.12);
  background: rgba(255,255,255,0.012);
  display: flex; flex-direction: column; gap: 5px;
}
.ds-lbl {
  font-size: 10px; color: rgba(200,170,255,0.85);
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 600;
}
.ds-row { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

/* Inputs */
.ds-input {
  background: rgba(25,12,55,0.92);
  border: 1px solid rgba(180,100,255,0.28);
  border-radius: 3px; color: #e8d5ff;
  padding: 4px 7px; font-size: 12px;
  outline: none; font-family: inherit;
}
.ds-input:focus { border-color: rgba(180,100,255,0.65); }
.ds-select { width: 100%; height: 28px; }
.ds-small { font-size: 11px; color: rgba(200,160,255,0.7); min-width: 16px; text-align: center; }

/* Buttons inside panel */
.ds-btn {
  background: rgba(40,20,80,0.6);
  border: 1px solid rgba(180,100,255,0.35);
  color: #d4a0ff; font-size: 11px; padding: 4px 9px;
  border-radius: 3px; cursor: pointer; font-family: inherit;
  transition: opacity 0.15s; white-space: nowrap;
}
.ds-btn:hover { opacity: 0.82; color: #fff; }
.ds-btn.undo-btn  { border-color: rgba(255,200,80,0.5); color: #ffe080; }
.ds-btn.save-btn  { border-color: rgba(80,200,100,0.5); color: #80ffaa; }
.ds-btn.clear-btn { border-color: rgba(180,100,255,0.25); color: rgba(200,160,255,0.6); font-size: 10px; }
.ds-btn.danger    { border-color: rgba(255,80,80,0.45); color: #ff9080; }
.ds-btn.danger:hover { background: rgba(120,15,15,0.45); color: #fff; }

/* Color swatch trigger */
.ds-swatch {
  width: 24px; height: 24px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.3);
  cursor: pointer; flex-shrink: 0;
  transition: transform 0.1s;
}
.ds-swatch:hover { transform: scale(1.12); }

/* Opacity slider */
input[type=range].ds-range {
  flex: 1; height: 4px; accent-color: #8040cc;
}

/* ================================================================
   OFFICE-STYLE COLOR PICKER
   ================================================================ */
#ds-cp-wrap {
  display: none;
  position: fixed; z-index: 9800;
  background: rgba(10,5,28,0.99);
  border: 1px solid rgba(180,100,255,0.45);
  border-radius: 8px; padding: 12px; width: 238px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  font-family: inherit;
}
#ds-cp-wrap.open { display: block; }

.cp-section-lbl {
  font-size: 11px; font-weight: 700;
  color: rgba(200,170,255,0.85);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 0 0 5px;
}

/* Auto row */
.cp-auto-row {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 9px; padding-bottom: 9px;
  border-bottom: 1px solid rgba(180,100,255,0.15);
  cursor: pointer;
}
.cp-auto-sw {
  width: 20px; height: 20px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 2px; flex-shrink: 0;
}
.cp-auto-lbl { font-size: 12px; color: rgba(220,190,255,0.85); }
.cp-auto-row:hover .cp-auto-lbl { color: #fff; }

/* Theme grid — 10 cols */
.cp-theme-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px; margin-bottom: 10px;
}
.cp-sw {
  width: 18px; height: 18px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.15);
  cursor: pointer; transition: transform 0.1s;
}
.cp-sw:hover { transform: scale(1.25); z-index: 2; position: relative; outline: 1px solid #fff; }

/* Standard row */
.cp-std-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px; margin-bottom: 10px;
}

/* More colors */
.cp-more {
  font-size: 11px; color: rgba(180,140,255,0.8);
  cursor: pointer; display: flex; align-items: center; gap: 5px;
  padding-top: 8px; border-top: 1px solid rgba(180,100,255,0.15);
}
.cp-more:hover { color: #fff; }

/* Hidden native color input for More Colors */
#ds-cp-native { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

/* ================================================================
   MICRO-SAVE TOAST — green check per control
   ================================================================ */
#ds-save-toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 9999;
  background: rgba(30,100,55,0.22);
  border: 1px solid rgba(60,200,100,0.45);
  color: #72f0a0;
  padding: 7px 16px; border-radius: 6px;
  font-size: 13px; font-family: inherit;
  pointer-events: none;
  opacity: 0; transition: opacity 0.25s;
  display: flex; align-items: center; gap: 6px;
}
#ds-save-toast.show { opacity: 1; }

/* ================================================================
   RESET CONFIRM MODAL
   ================================================================ */
#ds-reset-modal {
  display: none;
  position: fixed; inset: 0; z-index: 9900;
  background: rgba(0,0,0,0.75);
  align-items: center; justify-content: center;
  font-family: inherit;
}
#ds-reset-modal.open { display: flex; }
#ds-reset-inner {
  background: #0c0720;
  border: 1px solid rgba(255,80,80,0.4);
  border-radius: 10px; padding: 24px 28px;
  width: 360px; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
#ds-reset-inner h3 {
  font-size: 16px; color: #ff9090; margin-bottom: 10px;
}
#ds-reset-inner p {
  font-size: 13px; color: rgba(220,190,255,0.8);
  line-height: 1.6; margin-bottom: 18px;
}
.ds-reset-btns { display: flex; gap: 10px; justify-content: center; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 500px) {
  #ds-panel { width: 100%; border-radius: 0; }
  #ds-edit-toolbar { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 5px; }
  .ds-tb-btn { font-size: 11px; padding: 4px 8px; }
}
