/* ============================================================
   builder.css — Chart Builder UI (sidebar + preview chrome)
   These styles apply only to the builder page itself.
   For styles applied to the slide content, see theme.css.
   ============================================================ */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0d0d1a;
  color: #e8edf2;
}

/* ================================================================
   SIDEBAR
================================================================ */
#sidebar {
  width: 420px;
  min-width: 420px;
  height: 100vh;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2d3561;
  overflow: hidden;
}

/* ---- Tabs ---- */
#sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #2d3561;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #7a8fa6;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tab-btn:hover {
  color: #c8d4e0;
  background: rgba(45, 53, 97, 0.3);
}

.tab-btn.active {
  color: #4fc3f7;
  border-bottom-color: #4fc3f7;
}

.tab-panel { display: block; }

#sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  scrollbar-width: thin;
  scrollbar-color: #2d3561 transparent;
}

#sidebar-scroll::-webkit-scrollbar { width: 5px; }
#sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
#sidebar-scroll::-webkit-scrollbar-thumb { background: #2d3561; border-radius: 3px; }

/* ---- Section label ---- */
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: #7a8fa6;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  margin-top: 18px;
}
.section-label:first-child { margin-top: 0; }

/* ---- Type selector grid ---- */
#type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.type-card {
  background: #2d3561;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.type-card:hover {
  background: #3a4478;
  border-color: #4fc3f7;
}

.type-card.active {
  background: #1a3a5c;
  border-color: #4fc3f7;
  box-shadow: 0 0 0 1px #4fc3f740;
}

.type-card .tc-icon { font-size: 22px; line-height: 1; }
.type-card .tc-label { font-size: 11px; color: #c8d4e0; font-weight: 500; }
.type-card.active .tc-label { color: #4fc3f7; }

/* ---- Inputs ---- */
label {
  display: block;
  font-size: 12px;
  color: #7a8fa6;
  margin-bottom: 4px;
  margin-top: 12px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: #243040;
  border: 1px solid #2d3f52;
  border-radius: 7px;
  color: #e8edf2;
  font-size: 14px;
  font-family: inherit;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: #4fc3f7;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

textarea.monospace {
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
}

input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  padding: 2px;
  background: #243040;
  cursor: pointer;
}

/* ---- Dynamic rows ---- */
.row-editor {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.row-editor input { flex: 1; }
.row-editor input.input-num { width: 70px; flex: 0 0 70px; }
.row-editor input.input-emoji { width: 52px; flex: 0 0 52px; text-align: center; }
.row-editor input[type="color"] { width: 32px; flex: 0 0 32px; padding: 2px; }

.btn-remove {
  background: #3a1a2a;
  border: 1px solid #6b3040;
  color: #ff6b6b;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-remove:hover { background: #5a2030; }

.btn-add {
  width: 100%;
  background: #1a2d1a;
  border: 1px dashed #3a6a3a;
  color: #7ac77a;
  border-radius: 7px;
  padding: 7px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 4px;
  transition: all 0.15s;
}

.btn-add:hover { background: #243a24; border-color: #5aaa5a; }

/* ---- Columns input (table) ---- */
.col-input-hint {
  font-size: 11px;
  color: #566778;
  margin-top: 3px;
}

/* ---- Font picker ---- */
.font-current {
  background: #1a3a5c;
  border: 1px solid #4fc3f7;
  border-radius: 7px;
  padding: 12px 14px;
  font-size: 16px;
  color: #4fc3f7;
  margin-bottom: 10px;
  word-break: break-word;
}

.font-search {
  width: 100%;
  background: #243040;
  border: 1px solid #2d3f52;
  border-radius: 7px;
  color: #e8edf2;
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  margin-bottom: 10px;
}

.font-search:focus { border-color: #4fc3f7; }

.font-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 10px;
  background: #243040;
  border: 1px solid #2d3f52;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: #c8d4e0;
  user-select: none;
}
.font-filter-row:hover { border-color: #4fc3f7; }
.font-filter-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: #4fc3f7;
  cursor: pointer;
}

.font-status {
  font-size: 11px;
  color: #7a8fa6;
  margin-bottom: 10px;
  line-height: 1.4;
}

.font-status.warn { color: #ffb74d; }
.font-status.info { color: #7a8fa6; }

.font-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.font-option {
  background: #243040;
  border: 2px solid transparent;
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  content-visibility: auto;
  contain-intrinsic-size: 0 60px;
}

.font-option:hover {
  background: #2d3a4d;
  border-color: #4fc3f74d;
}

.font-option.active {
  background: #1a3a5c;
  border-color: #4fc3f7;
}

.font-option .fo-name {
  font-size: 16px;
  font-weight: 500;
  color: #e8edf2;
  margin-bottom: 2px;
}

.font-option .fo-sample {
  font-size: 12px;
  color: #7a8fa6;
}

.font-option.active .fo-name { color: #4fc3f7; }

/* ---- Range slider ---- */
.range-val {
  float: right;
  color: #4fc3f7;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: monospace;
}

.size-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #243040;
  border-radius: 3px;
  outline: none;
  margin: 4px 0 4px;
}
.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #4fc3f7;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #1a1a2e;
}
.size-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #4fc3f7;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #1a1a2e;
}

/* ---- Field row with color+font buttons ---- */
.field-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
}
.field-row input[type="text"],
.field-row input[type="number"],
.field-row textarea {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;  /* override default */
}
.field-row--area { align-items: flex-start; }

.field-clr {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px;
  padding: 2px !important;
  border-radius: 5px !important;
  flex-shrink: 0;
  cursor: pointer;
}
.field-fnt {
  width: 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #2d3f52;
  border-radius: 5px;
  background: #243040;
  color: #c8d4e0;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1;
}
.field-fnt:hover { border-color: #4fc3f7; background: #1a3a5c; }
.field-fnt.has-font { border-color: #4fc3f7; color: #4fc3f7; }

.field-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

/* Font popover */
#font-popover {
  position: fixed;
  z-index: 9999;
  background: #1a1a2e;
  border: 1px solid #3d4d60;
  border-radius: 10px;
  padding: 10px;
  width: 230px;
  max-height: 340px;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#font-popover.open { display: flex; }
#fp-search {
  width: 100%;
  background: #243040;
  border: 1px solid #2d3f52;
  border-radius: 6px;
  color: #e8edf2;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  margin-bottom: 6px;
  box-sizing: border-box;
}
#fp-search:focus { border-color: #4fc3f7; }
#fp-cyrillic-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #7a8fa6;
  margin-bottom: 6px;
  user-select: none;
  cursor: pointer;
}
#fp-cyrillic-row input { width: auto; margin: 0; accent-color: #4fc3f7; }
#fp-list {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #2d3561 transparent;
}
.fp-item {
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 5px;
  font-size: 13px;
  color: #c8d4e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fp-item:hover { background: #2d3a4d; }
.fp-item.fp-active { background: #1a3a5c; color: #4fc3f7; }
#fp-load-system {
  margin-top: 6px;
  width: 100%;
  background: #1a2d1a;
  border: 1px dashed #3a6a3a;
  color: #7ac77a;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
#fp-load-system:hover { background: #243a24; }

/* Text category grid in Style tab */
.text-cat-grid {
  display: grid;
  grid-template-columns: 1fr 52px auto auto;
  align-items: center;
  gap: 6px 8px;
  margin-bottom: 8px;
}
.tc-cat-name {
  font-size: 12px;
  color: #c8d4e0;
  font-weight: 500;
}
.field-sz {
  width: 52px;
  height: 28px;
  background: #1a2535;
  border: 1px solid #2d3f52;
  border-radius: 5px;
  color: #c8d4e0;
  font-size: 12px;
  text-align: center;
  padding: 0 4px;
  -moz-appearance: textfield;
}
.field-sz::-webkit-outer-spin-button,
.field-sz::-webkit-inner-spin-button { -webkit-appearance: none; }
.field-sz:focus { outline: none; border-color: #4fc3f7; }
.field-sz::placeholder { color: #3d5268; }

/* Style category hint badge in Content tab */
.cat-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: transparent;
  color: #4a6070;
  font-size: 9px;
  font-weight: 700;
  font-style: normal;
  cursor: help;
  margin-left: 3px;
  vertical-align: middle;
  border: 1px solid #2d3f52;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.cat-hint:hover { color: #4fc3f7; border-color: #4fc3f7; }

/* Custom tooltip (replaces native title= which breaks inside overflow containers) */
#cat-tooltip {
  position: fixed;
  background: #1a2535;
  color: #c8d4e0;
  border: 1px solid #4fc3f7;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  max-width: 240px;
  line-height: 1.4;
  pointer-events: none;
  z-index: 9999;
  display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

/* Theme toggle in style tab */
.theme-toggle { display: flex; gap: 8px; margin-bottom: 4px; }
.theme-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid #2d3f52;
  border-radius: 7px;
  background: #243040;
  color: #c8d4e0;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.theme-btn:hover { border-color: #4fc3f7; }
.theme-btn.active { background: #1a3a5c; border-color: #4fc3f7; color: #4fc3f7; font-weight: 600; }

/* ---- CSS upload ---- */
#css-upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

#css-upload-label {
  background: #243040;
  border: 1px solid #2d3f52;
  border-radius: 7px;
  color: #c8d4e0;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}

#css-upload-label:hover { border-color: #4fc3f7; }

#css-file-input { display: none; }

/* ---- Action buttons ---- */
#sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid #2d3561;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.action-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.action-btn:hover  { opacity: 0.9; }
.action-btn:active { transform: scale(0.97); }
.action-btn:disabled { opacity: 0.5; cursor: wait; }

.btn-import      { background: #5e35b1; color: #fff; }
.btn-export-main { background: #00838f; color: #fff; }

/* Export dropdown */
.export-wrap {
  flex: 1;
  position: relative;
}
.export-wrap .action-btn { width: 100%; }

#export-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: #1a2535;
  border: 1px solid #2d3f52;
  border-radius: 8px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 200;
}
#export-menu.open { display: flex; }
#export-menu button {
  background: none;
  border: none;
  color: #c8d4e0;
  padding: 10px 16px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.1s;
}
#export-menu button:hover { background: #243040; color: #fff; }
#export-menu button:disabled { opacity: 0.5; cursor: wait; }

/* Round preview overlay buttons */
#preview-controls {
  position: absolute;
  bottom: 32px;
  left: 32px;
  display: flex;
  gap: 10px;
  z-index: 10;
}
.preview-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 30, 50, 0.35);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.1s;
  line-height: 1;
}
.preview-btn:hover  { background: rgba(20, 30, 50, 0.6); }
.preview-btn:active { transform: scale(0.93); }

/* ================================================================
   PREVIEW PANEL
================================================================ */
#preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f0f0f0;
  overflow: hidden;
}

#preview-header {
  background: #e8eaf0;
  padding: 10px 20px;
  border-bottom: 1px solid #ccc;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#app-title {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: 0.3px;
}
#app-title em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  color: #7a8fa6;
  margin-left: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#preview-dims {
  font-size: 11px;
  font-weight: 400;
  color: #888;
  font-family: monospace;
}

#preview-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  position: relative;
}

#preview-aspect {
  position: relative;
  background: transparent;
  border: 2px dashed #6688aa;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

#preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  border: none;
  transform-origin: top left;
  display: block;
}
