/* ============================================
   TOVARIUM — РЕДАКТОР
   Тулбар, ліва панель блоків, центральне
   полотно, права панель налаштувань
   ============================================ */

/* Головний грід редактора */
.editor-screen {
  display: none;
  height: 100vh;
  grid-template-columns: 280px 1fr 300px;
  grid-template-rows: 54px 1fr;
  overflow: hidden;
}

.editor-screen.visible {
  display: grid;
}

/* ============================================
   ТУЛБАР (верхня панель)
   ============================================ */
.editor-toolbar {
  grid-column: 1 / -1;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 6px;
  z-index: var(--z-sticky);
}

.toolbar-brand {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-right: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.toolbar-sep {
  width: 1px;
  height: 26px;
  background: var(--border-primary);
  margin: 0 6px;
  flex-shrink: 0;
}

.toolbar-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-fast);
  white-space: nowrap;
  border: 1px solid transparent;
}

.toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--neon-blue);
  border-color: var(--border-secondary);
}

.toolbar-btn.btn-accent {
  background: var(--gradient-btn);
  color: #fff;
  border: none;
}

.toolbar-btn.btn-accent:hover {
  background: var(--gradient-btn-hover);
  box-shadow: var(--shadow-glow-blue);
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Device toggle */
.toolbar-devices {
  display: flex;
  gap: 2px;
  background: var(--surface-input);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.device-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition-fast);
}

.device-btn.active {
  background: var(--surface-card);
  color: var(--neon-blue);
  box-shadow: var(--shadow-sm);
}

.device-btn:hover:not(.active) {
  color: var(--text-secondary);
}

/* ============================================
   ЛІВА ПАНЕЛЬ — БЛОКИ
   ============================================ */
.editor-left {
  background: var(--surface-sidebar);
  border-right: 1px solid var(--border-primary);
  overflow-y: auto;
  padding: 14px;
  min-height: 0; /* Для скролу в grid */
}

.panel-heading {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 4px;
}

/* Список блоків */
.block-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.block-item {
  background: var(--surface-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.block-item:hover {
  border-color: var(--neon-blue);
  background: var(--bg-hover);
  box-shadow: 0 2px 8px var(--glow-blue);
}

.block-item:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.block-item-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.block-item-info {
  flex: 1;
  min-width: 0;
}

.block-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.block-item-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   ЦЕНТРАЛЬНЕ ПОЛОТНО (CANVAS)
   ============================================ */
.editor-canvas {
  background: var(--bg-primary);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  position: relative;
  min-height: 0; /* Важливо для grid — дозволяє скрол */
}

.canvas-wrap {
  width: 100%;
  max-width: 1200px;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: visible;
  position: relative;
  transition: max-width 0.3s var(--ease-out);
}

/* Режими девайсів */
.canvas-wrap.view-tablet { max-width: 768px; }
.canvas-wrap.view-mobile { max-width: 375px; }

/* Зона дропу */
.canvas-drop-zone {
  min-height: 500px;
  padding: 0;
  position: relative;
}

.canvas-drop-zone.drag-over {
  outline: 3px dashed var(--neon-blue);
  outline-offset: -3px;
  background: rgba(0, 212, 255, 0.03);
}

/* Порожній стан */
.canvas-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.canvas-empty .empty-icon {
  font-size: 72px;
  margin-bottom: 20px;
  opacity: 0.4;
}

.canvas-empty h3 {
  font-family: var(--font-heading);
  font-size: 20px;
  margin-bottom: 8px;
  color: #999;
}

.canvas-empty p {
  font-size: 14px;
  color: #bbb;
}

/* Стилі для блоків всередині канвасу */
.tov-block {
  position: relative;
  transition: outline 0.2s;
}

.tov-block:hover {
  outline: 2px dashed rgba(0, 212, 255, 0.35);
}

.tov-block.selected {
  outline: 2px solid var(--neon-blue);
}

/* Хендл для перетягування блоку */
.tov-block-handle {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--neon-blue);
  color: #fff;
  font-size: 10px;
  padding: 2px 10px;
  border-radius: 4px;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.2s;
  font-family: var(--font-heading);
  white-space: nowrap;
  z-index: 10;
  pointer-events: auto;
}

.tov-block:hover .tov-block-handle {
  opacity: 1;
}

/* Кнопка видалення блоку */
.tov-block-delete {
  position: absolute;
  top: -14px;
  right: 8px;
  background: #ff5050;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
  z-index: 10;
}

.tov-block:hover .tov-block-delete {
  opacity: 1;
}

/* Стилі для редагованого контенту */
[contenteditable] {
  outline: 2px solid transparent;
  transition: outline-color 0.2s;
  cursor: text;
}

[contenteditable]:hover {
  outline-color: rgba(0, 212, 255, 0.3);
}

[contenteditable]:focus {
  outline-color: var(--neon-blue);
}

/* Заміна зображень */
.tov-img-replace {
  position: relative;
  cursor: pointer;
}

.tov-img-replace:hover::after {
  content: '📷 Натисніть щоб замінити';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-family: var(--font-body);
  border-radius: 4px;
  backdrop-filter: blur(2px);
}

/* ============================================
   ПРАВА ПАНЕЛЬ — НАЛАШТУВАННЯ
   ============================================ */
.editor-right {
  background: var(--surface-sidebar);
  border-left: 1px solid var(--border-primary);
  overflow-y: auto;
  padding: 14px;
  min-height: 0; /* Для скролу в grid */
}

.settings-section {
  margin-bottom: 20px;
}

.settings-section-title {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.setting-row {
  margin-bottom: 12px;
}

.setting-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  display: block;
}

/* ============================================
   RESPONSIVE — МОБІЛЬНА АДАПТАЦІЯ
   ============================================ */
@media (max-width: 1100px) {
  .editor-screen.visible {
    grid-template-columns: 1fr;
    grid-template-rows: 54px 1fr;
  }

  .editor-left,
  .editor-right {
    position: fixed;
    top: 54px;
    bottom: 0;
    width: 280px;
    z-index: var(--z-dropdown);
    transition: transform 0.3s var(--ease-out);
    box-shadow: var(--shadow-lg);
  }

  .editor-left {
    left: 0;
    transform: translateX(-100%);
  }

  .editor-right {
    right: 0;
    transform: translateX(100%);
  }

  .editor-left.panel-open {
    transform: translateX(0);
  }

  .editor-right.panel-open {
    transform: translateX(0);
  }
}

@media (max-width: 640px) {
  .editor-toolbar {
    padding: 0 8px;
    gap: 4px;
    overflow-x: auto;
  }

  .toolbar-btn {
    padding: 0 8px;
    font-size: 11px;
  }

  .toolbar-btn .btn-label {
    display: none;
  }
}
