/* ══════════════════════════════════════════════════════════
   Editor popisků – UI styly (světlý motiv)
   ══════════════════════════════════════════════════════════ */

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

:root {
  --ui-bg: #ffffff;
  --ui-panel: #f8f9fa;
  --ui-panel2: #f0f1f3;
  --ui-border: #e2e5e9;
  --ui-border-hover: #c7ccd3;
  --ui-accent: #2563eb;
  --ui-accent-light: #dbeafe;
  --ui-accent2: #f97316;
  --ui-text: #1a1a1a;
  --ui-muted: #6b7280;
  --ui-danger: #ef4444;
  --ui-success: #16a34a;
  --ui-success-light: #dcfce7;
  --ui-warning: #f59e0b;
  --sidebar-w: 320px;
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--ui-bg);
  color: var(--ui-text);
  height: 100vh;
  overflow: hidden;
}

/* ── TOOLBAR ── */
.toolbar {
  z-index: 200;
  background: var(--ui-bg);
  border-bottom: 1px solid var(--ui-border);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  height: 49px;
  flex-shrink: 0;
}
.toolbar-title {
  font-family: 'DM Serif Display', serif;
  font-size: 16px; color: var(--ui-accent);
  margin-right: 12px; white-space: nowrap;
}
.toolbar-group {
  display: flex; align-items: center; gap: 4px;
}
.toolbar-divider {
  width: 1px; height: 24px; background: var(--ui-border); margin: 0 6px;
}
.toolbar-hint {
  font-size: 11px; color: var(--ui-muted);
  display: flex; align-items: center; gap: 5px; margin-right: auto;
  white-space: nowrap;
}
.toolbar-hint span {
  background: var(--ui-panel2); border-radius: 4px;
  padding: 2px 6px; font-size: 10px; color: var(--ui-text);
}

/* ── BUTTONS ── */
.btn {
  padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600;
  transition: all .15s; display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--ui-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-secondary { background: var(--ui-panel2); color: var(--ui-text); border: 1px solid var(--ui-border); }
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; border-color: var(--ui-border-hover); }
.btn-success { background: var(--ui-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: transparent; color: var(--ui-danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; color: var(--ui-muted); border: none; padding: 6px 8px; }
.btn-ghost:hover { color: var(--ui-text); background: var(--ui-panel2); }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 5px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; }

/* Preview mode toggle */
.preview-mode-group { display: flex; border: 1px solid var(--ui-border); border-radius: 6px; overflow: hidden; }
.preview-mode-btn {
  padding: 5px 12px; border: none; background: none; cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--ui-muted);
  font-family: 'DM Sans', sans-serif; transition: all .15s;
}
.preview-mode-btn:not(:last-child) { border-right: 1px solid var(--ui-border); }
.preview-mode-btn.active { background: var(--ui-accent); color: #fff; }
.preview-mode-btn:hover:not(.active) { background: var(--ui-panel2); }

/* ── LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100vh - 49px);
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--ui-panel);
  border-right: 1px solid var(--ui-border);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-bg);
  position: sticky; top: 0; z-index: 10;
}
.sidebar-tab {
  flex: 1; padding: 10px 4px; text-align: center;
  font-size: 11px; font-weight: 600; color: var(--ui-muted);
  cursor: pointer; border: none; background: none;
  letter-spacing: .03em; transition: all .15s;
  border-bottom: 2px solid transparent;
  font-family: 'DM Sans', sans-serif;
}
.sidebar-tab:hover { color: var(--ui-text); }
.sidebar-tab.active { color: var(--ui-accent); border-bottom-color: var(--ui-accent); }

.sidebar-panel { display: none; padding: 14px; flex-direction: column; gap: 12px; flex: 1; }
.sidebar-panel.active { display: flex; }

.sidebar-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ui-muted); margin-bottom: 4px;
}

/* ── Block list (tab Bloky) ── */
.block-list { display: flex; flex-direction: column; gap: 4px; }
.block-item {
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 7px; padding: 7px 10px;
  display: flex; align-items: center; gap: 7px;
  cursor: default; transition: all .15s; font-size: 12px;
}
.block-item:hover { border-color: var(--ui-border-hover); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.block-item.hidden-block { opacity: .4; }
.block-item.dragging-sidebar { opacity: .3; background: var(--ui-accent-light); }
.block-item .block-icon { font-size: 14px; flex-shrink: 0; }
.block-item .block-label { flex: 1; font-weight: 500; font-size: 12px; }
.block-item .block-type-badge {
  font-size: 9px; color: var(--ui-muted); background: var(--ui-panel2);
  padding: 1px 5px; border-radius: 3px;
}

/* Toggle switch */
.block-toggle {
  width: 30px; height: 16px; border-radius: 999px;
  background: #d1d5db; border: none; cursor: pointer;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.block-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; transition: all .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.block-toggle.active { background: var(--ui-accent); }
.block-toggle.active::after { left: 16px; }

/* Sidebar block buttons */
.block-item-actions { display: flex; gap: 2px; }
.block-item-btn {
  width: 22px; height: 22px; border: none; background: none;
  cursor: pointer; border-radius: 4px; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ui-muted); transition: all .15s;
}
.block-item-btn:hover { background: var(--ui-panel2); color: var(--ui-text); }
.block-item-btn.btn-del:hover { background: #fef2f2; color: var(--ui-danger); }

.drag-handle, .drag-handle-preview { color: var(--ui-border-hover); cursor: grab; font-size: 12px; user-select: none; }
.drag-handle:hover, .drag-handle-preview:hover { color: var(--ui-muted); }
.drag-handle:active, .drag-handle-preview:active { cursor: grabbing; }

/* ── Add block catalog (tab Přidat blok) ── */
.block-catalog-category { margin-bottom: 12px; }
.block-catalog-category-title {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ui-muted);
  margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--ui-border);
}
.block-catalog-list { display: flex; flex-direction: column; gap: 3px; }
.block-catalog-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
  transition: all .15s; font-size: 12px; border: 1px solid transparent;
}
.block-catalog-item:hover { background: var(--ui-accent-light); border-color: var(--ui-accent); }
.block-catalog-item .block-icon { font-size: 14px; }
.block-catalog-item .block-label { font-weight: 500; }

/* ── Image manager (tab Fotky) ── */
.img-add-row { display: flex; gap: 6px; }
.img-add-row input {
  flex: 1; background: var(--ui-bg); border: 1px solid var(--ui-border);
  border-radius: 6px; padding: 7px 10px; font-size: 11px;
  color: var(--ui-text); outline: none; font-family: 'DM Sans', sans-serif;
}
.img-add-row input:focus { border-color: var(--ui-accent); box-shadow: 0 0 0 2px var(--ui-accent-light); }
.img-add-row input::placeholder { color: #aaa; }

.img-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.img-thumb {
  position: relative; cursor: pointer; border-radius: 6px;
  overflow: hidden; border: 2px solid transparent;
  transition: all .15s; aspect-ratio: 1; background: var(--ui-panel2);
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-thumb:hover { border-color: var(--ui-accent); }
.img-thumb.selected-for-swap { border-color: var(--ui-accent2); box-shadow: 0 0 0 2px var(--ui-accent2); }
.img-thumb-actions {
  position: absolute; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end; justify-content: center;
  gap: 4px; padding: 4px; opacity: 0; transition: opacity .15s;
}
.img-thumb:hover .img-thumb-actions { opacity: 1; }
.img-action-btn {
  font-size: 10px; padding: 3px 6px; border-radius: 4px;
  border: none; cursor: pointer; font-weight: 600;
  font-family: 'DM Sans', sans-serif;
}
.img-label-badge {
  position: absolute; top: 3px; left: 3px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 8px;
  padding: 2px 5px; border-radius: 3px;
  max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Swap banner */
.swap-banner {
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 7px;
  padding: 10px 12px; font-size: 12px; color: #9a3412; display: none;
}
.swap-banner.active { display: block; }

/* ── Settings panel ── */
.settings-group { margin-bottom: 16px; }
.settings-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; font-size: 12px;
}
.settings-row label { flex: 1; color: var(--ui-muted); font-weight: 500; }
.settings-row input[type="color"] {
  width: 32px; height: 24px; border: 1px solid var(--ui-border);
  border-radius: 4px; cursor: pointer; padding: 1px;
}

/* ── PREVIEW ── */
.preview-wrap {
  overflow-y: auto; background: #eaecef;
  display: flex; justify-content: center;
  padding: 24px;
  align-items: flex-start;
}
.preview-inner {
  width: 100%; max-width: 100%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  border-radius: 8px;
  overflow: hidden;
  transition: max-width .3s ease;
}
.preview-inner.mode-tablet { max-width: 768px; }
.preview-inner.mode-mobile { max-width: 375px; }

/* Override full-bleed in preview (100vw = viewport, not container) */
.preview-inner .cp-bleed-gray,
.preview-inner .cp-bleed-dark,
.preview-inner .cp-bleed-black {
  width: 100%; left: auto; right: auto;
  margin-left: 0; margin-right: 0;
}

.preview-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px;
  color: var(--ui-muted); text-align: center;
}
.preview-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
.preview-empty h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--ui-text); }
.preview-empty p { font-size: 13px; max-width: 300px; }

/* Editable text in preview */
.preview-inner [contenteditable] { outline: none; }
.preview-inner [contenteditable]:hover {
  background: rgba(37, 99, 235, .04);
  border-radius: 3px;
  outline: 1px dashed rgba(37, 99, 235, .25);
}
.preview-inner [contenteditable]:focus {
  background: rgba(37, 99, 235, .06);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .2);
  border-radius: 3px; outline: none;
}

/* Block in preview */
.cp-block { position: relative; transition: opacity .15s; }
.cp-block.dragging { opacity: .3; }
.cp-block.drag-over-top::before {
  content: ''; position: absolute; top: -3px; left: 0; right: 0;
  height: 4px; background: var(--ui-accent2); border-radius: 2px; z-index: 10;
}
.cp-block.drag-over-bottom::after {
  content: ''; position: absolute; bottom: -3px; left: 0; right: 0;
  height: 4px; background: var(--ui-accent2); border-radius: 2px; z-index: 10;
}

/* Block controls overlay */
.block-controls {
  position: absolute; top: 8px; right: 8px; z-index: 20;
  display: flex; gap: 3px; opacity: 0; transition: opacity .15s;
}
.cp-block:hover > .block-controls,
.cp-block:hover > div > .block-controls,
.cp-block:hover > section > .block-controls { opacity: 1; }
.block-ctrl-btn {
  width: 28px; height: 28px; border-radius: 5px;
  background: rgba(255,255,255,.9); border: 1px solid var(--ui-border);
  color: var(--ui-text); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.block-ctrl-btn:hover { background: var(--ui-accent); color: #fff; border-color: var(--ui-accent); }
.block-ctrl-btn.btn-del-preview:hover { background: var(--ui-danger); border-color: var(--ui-danger); }

/* Demo badge */
.demo-badge {
  position: absolute; top: 8px; left: 8px; z-index: 20;
  display: flex; gap: 4px; align-items: center;
  background: #fef3c7; border: 1px solid #fcd34d;
  color: #92400e; font-size: 10px; font-weight: 600;
  padding: 3px 8px; border-radius: 5px;
  opacity: 0; transition: opacity .15s;
}
.cp-block:hover .demo-badge { opacity: 1; }
.demo-clear-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: #92400e; padding: 0 0 0 4px;
  font-weight: 700; line-height: 1;
}
.demo-clear-btn:hover { color: var(--ui-danger); }

/* Swap overlay on images */
.swappable-img-wrap { position: relative; display: inline-block; width: 100%; }
.swap-img-btn {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.75); color: #fff; border: none; border-radius: 6px;
  padding: 5px 12px; font-size: 11px; font-weight: 600; cursor: pointer;
  opacity: 0; transition: opacity .15s; white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
}
.swappable-img-wrap:hover .swap-img-btn { opacity: 1; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 500; display: none; align-items: center;
  justify-content: center; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--ui-bg); border: 1px solid var(--ui-border);
  border-radius: 12px; width: 100%; max-width: 800px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--ui-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 15px; }
.modal-close {
  background: none; border: none; color: var(--ui-muted);
  font-size: 20px; cursor: pointer; line-height: 1;
  width: 28px; height: 28px; display: flex; align-items: center;
  justify-content: center; border-radius: 5px;
}
.modal-close:hover { background: var(--ui-panel2); color: var(--ui-text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--ui-border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* Code output */
.code-output {
  background: #1e293b; border-radius: 8px; padding: 16px;
  font-family: 'Courier New', monospace; font-size: 11px;
  line-height: 1.6; color: #a5f3fc; white-space: pre-wrap;
  word-break: break-all; max-height: 50vh; overflow-y: auto;
}
.copy-feedback {
  color: var(--ui-success); font-size: 12px; font-weight: 600;
  opacity: 0; transition: opacity .3s;
}
.copy-feedback.show { opacity: 1; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ui-text); color: #fff;
  padding: 10px 20px; border-radius: 8px;
  font-weight: 600; font-size: 12px; opacity: 0;
  transition: all .3s; pointer-events: none; z-index: 999;
  white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-8px); }

/* ── Quill overrides ── */
.ql-bubble .ql-tooltip { z-index: 100; }
.ql-bubble .ql-editor { padding: 0; }
.ql-bubble .ql-editor p { margin: 0 0 12px; }
.ql-bubble .ql-editor:focus { box-shadow: none; }
.ql-container.ql-bubble { border: none; }

/* ── File input hidden ── */
.file-input-hidden { display: none; }

/* ── Preset cards ── */
.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--ui-border); transition: all .15s;
}
.preset-item:hover { border-color: var(--ui-accent); background: var(--ui-accent-light); }
.preset-item-info { flex: 1; }
.preset-item-info h4 { font-size: 13px; font-weight: 600; margin: 0 0 2px; }
.preset-item-info p { font-size: 11px; color: var(--ui-muted); margin: 0; }
.preset-item-count {
  font-size: 11px; font-weight: 700; color: var(--ui-accent);
  background: var(--ui-accent-light); padding: 2px 7px; border-radius: 4px;
}

/* ── Remove-item button ── */
.removable-item { position: relative; }
.item-remove-btn {
  position: absolute; right: -6px; top: -6px; z-index: 10;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #fff; background: var(--ui-danger); color: #fff;
  font-size: 10px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.removable-item:hover > .item-remove-btn { opacity: .75; }
.item-remove-btn:hover { opacity: 1 !important; transform: scale(1.1); }

/* ── Table row remove button (fix: <tr> can't be position:relative) ── */
.td-row-remove {
  width: 0; padding: 0 !important; border: none !important;
  background: transparent !important; position: relative; overflow: visible;
}
.td-row-remove .item-remove-btn {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  opacity: 0; transition: opacity .15s;
}
tr:hover .td-row-remove .item-remove-btn { opacity: .75; }
.td-row-remove .item-remove-btn:hover { opacity: 1 !important; transform: translateY(-50%) scale(1.1); }

/* ── Inline URL input ── */
.inline-url-input {
  width: 100%; padding: 5px 10px; margin-top: 6px;
  border: 1px dashed var(--ui-border); border-radius: 6px;
  font-size: 11px; color: var(--ui-muted);
  background: var(--ui-panel); font-family: 'DM Sans', monospace;
  transition: border-color .15s;
}
.inline-url-input:focus {
  border-color: var(--ui-accent); outline: none;
  color: var(--ui-text); border-style: solid;
}
.inline-url-input::placeholder { color: #bbb; }

/* ── Image size slider ── */
.img-size-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 12px;
  background: var(--ui-panel);
  border-radius: 6px;
  border: 1px solid var(--ui-border);
}
.img-size-label {
  font-size: 11px;
  color: var(--ui-muted);
  font-weight: 500;
  white-space: nowrap;
  min-width: 50px;
  font-family: 'DM Sans', sans-serif;
}
.img-size-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--ui-border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.img-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ui-accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* ── Column selector ── */
.col-selector-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 6px 0;
}
.col-selector-label {
  font-size: 11px;
  color: var(--ui-muted);
  font-weight: 500;
  margin-right: 4px;
  font-family: 'DM Sans', sans-serif;
}

/* ── Comparison table column remove ── */
.col-remove-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #fff;
  background: var(--ui-danger);
  color: #fff;
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
  z-index: 5;
}
th:hover .col-remove-btn { opacity: .75; }
.col-remove-btn:hover { opacity: 1 !important; transform: scale(1.1); }
.compare-add-col:hover { color: var(--ui-accent) !important; }

/* ── Product URL loader row ── */
.product-url-add {
  display: flex; gap: 6px; margin-top: 10px;
}
.product-url-add .inline-url-input { flex: 1; margin-top: 0; }
