/* ============================================
   EDITORS STYLES - Стили для редакторов
   ============================================ */

/* Общие стили редакторов */

.page-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f7fa;
  border: 1px solid #e0e3e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px;
  background: linear-gradient(135deg, #f8f9fb 0%, #f0f3f8 100%);
  border-bottom: 1px solid #e0e3e8;
  align-items: center;
  align-content: flex-start;
  min-width: 0;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0 4px;
  border-right: 1px solid #d0d3d8;
  min-width: 0;
}

.toolbar-group:last-of-type,
.toolbar-group.toolbar-end {
  border-right: none;
  margin-left: auto;
}

.btn-toolbar {
  background: white;
  border: 1px solid #d0d3d8;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #2c3e50;
  transition: all 0.15s ease;
  white-space: nowrap;
  max-width: 100%;
}

.btn-toolbar:hover:not(:disabled) {
  background: linear-gradient(135deg, #e8ecf2 0%, #f0f3f8 100%);
  border-color: #0f4e8a;
  color: #0f4e8a;
}

.btn-toolbar:active:not(:disabled) {
  background: #d5dce8;
  border-color: #0a3a63;
  transform: scale(0.98);
}

.btn-toolbar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-toolbar.btn-primary {
  background: linear-gradient(135deg, #0f4e8a 0%, #2aa7a6 100%);
  color: white;
  border: none;
  font-weight: 600;
}

.btn-toolbar.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0a3a63 0%, #1d7e7d 100%);
  box-shadow: 0 4px 12px rgba(15, 78, 138, 0.3);
}

.editor-area {
  display: flex;
  flex-direction: column;
  height: 400px;
  position: relative;
  min-width: 0;
}

.editor-visual,
.editor-code {
  flex: 1;
  padding: 16px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1a1a1a;
  resize: none;
  border: none;
  outline: none;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.editor-visual {
  background: white;
  overflow: auto;
}

.editor-visual:focus {
  background: #fafbfc;
}

.editor-code {
  background: #2c3e50;
  color: #ecf0f1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  tab-size: 2;
  overflow: auto;
}

.editor-code:focus {
  background: #34495e;
}

/* ============================================
   MODERN EDITOR STYLES - Современный редактор
   ============================================ */

.modern-toolbar {
  gap: 2px;
}

.modern-toolbar .toolbar-group {
  padding: 0 6px;
}

.modern-editor {
  background: white;
}

.modern-editor img {
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 4px;
}

.modern-editor table {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 16px 0;
  border: 1px solid #e0e3e8;
}

.modern-editor table td,
.modern-editor table th {
  border: 1px solid #e0e3e8;
  padding: 8px 12px;
  text-align: left;
}

.modern-editor table th {
  background: #f5f7fa;
  font-weight: 600;
}

.modern-editor pre {
  background: #2c3e50;
  color: #ecf0f1;
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 12px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.modern-editor code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
}

.modern-editor blockquote {
  border-left: 4px solid #2aa7a6;
  padding-left: 16px;
  margin: 16px 0;
  color: #555;
  font-style: italic;
}

/* ============================================
   CLASSIC EDITOR STYLES - Классический редактор
   ============================================ */

.classic-toolbar {
  gap: 2px;
}

.classic-toolbar .toolbar-group {
  padding: 0 4px;
}

.classic-editor {
  background: white;
  font-size: 14px;
}

/* ============================================
   TILDA EDITOR STYLES - Визуальный редактор
   ============================================ */

.tilda-editor-container {
  display: flex;
  gap: 0;
  height: 400px;
  min-width: 0;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f7fa;
  border: 1px solid #e0e3e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tilda-blocks-panel {
  flex: 0 0 180px;
  width: 180px;
  background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
  color: white;
  padding: 16px;
  overflow-y: auto;
  border-right: 2px solid #1a252f;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tilda-blocks-panel h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #2aa7a6;
}

.blocks-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.block-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 8px 10px;
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
}

.block-btn span {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(42, 167, 166, 0.2);
  border-radius: 3px;
  font-weight: 600;
}

.block-btn:hover {
  background: rgba(42, 167, 166, 0.3);
  border-color: #2aa7a6;
  transform: translateX(2px);
}

.block-btn:active {
  transform: translateX(0);
  background: rgba(42, 167, 166, 0.4);
}

.tilda-editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tilda-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8f9fb 0%, #f0f3f8 100%);
  border-bottom: 1px solid #e0e3e8;
  font-weight: 500;
  font-size: 13px;
  color: #555;
}

.toolbar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tilda-canvas {
  flex: 1;
  padding: 20px;
  overflow: auto;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.canvas-paste-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 14px;
  text-align: center;
  font-style: italic;
}

.tilda-canvas.drag-over {
  background: rgba(42, 167, 166, 0.05);
  border: 2px dashed #2aa7a6;
  border-radius: 4px;
}

/* Блоки редактора Tilda */

.tilda-block {
  background: white;
  border: 1px solid #e0e3e8;
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: grab;
  min-width: 0;
}

.tilda-block:hover {
  border-color: #2aa7a6;
  box-shadow: 0 2px 8px rgba(42, 167, 166, 0.1);
}

.tilda-block.selected {
  border: 2px solid #0f4e8a;
  box-shadow: 0 0 0 3px rgba(15, 78, 138, 0.1);
}

.tilda-block.dragging {
  opacity: 0.7;
  cursor: grabbing;
}

.block-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f8f9fb 0%, #f0f3f8 100%);
  border-bottom: 1px solid #e0e3e8;
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.block-type {
  color: #2aa7a6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.block-controls {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-control {
  background: white;
  border: 1px solid #d0d3d8;
  border-radius: 3px;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  transition: all 0.15s ease;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-control:hover {
  background: #f5f7fa;
  border-color: #0f4e8a;
  color: #0f4e8a;
}

.btn-control:active {
  background: #e8ecf2;
  transform: scale(0.95);
}

.block-content {
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
  min-width: 0;
  overflow-wrap: anywhere;
}

.block-content [contenteditable] {
  outline: none;
  min-height: 40px;
}

.block-content [contenteditable]:focus {
  background: #fafbfc;
  padding: 4px 6px;
  border-radius: 3px;
  margin: -4px -6px;
}

.image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  background: #f5f7fa;
  border: 2px dashed #e0e3e8;
  border-radius: 4px;
  text-align: center;
  min-width: 0;
}

.image-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid #d0d3d8;
  border-radius: 4px;
  font-size: 13px;
  font-family: monospace;
}

.image-input:focus {
  border-color: #2aa7a6;
  outline: none;
}

.block-content img {
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  display: block;
  border-radius: 4px;
}

.block-content table {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 8px 0;
}

.block-content table td {
  border: 1px solid #e0e3e8;
  padding: 8px;
  font-size: 13px;
  word-break: break-word;
}

.block-code {
  display: block;
  background: #2c3e50;
  color: #ecf0f1;
  padding: 12px !important;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  outline: none;
}

.tilda-code-view {
  flex: 1;
  padding: 16px;
  background: #2c3e50;
  color: #ecf0f1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  border: none;
  tab-size: 2;
  resize: none;
  outline: none;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
}

.tilda-code-view:focus {
  background: #34495e;
}

/* Адаптивность */

@media (max-width: 1120px) {
  .tilda-editor-container {
    height: auto;
    flex-direction: column;
  }

  .tilda-blocks-panel {
    flex: none;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 2px solid #1a252f;
  }

  .blocks-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .editor-area,
  .tilda-canvas {
    height: 400px;
  }

  .toolbar-group {
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .editor-area,
  .tilda-canvas {
    height: min(62vh, 400px);
  }

  .editor-toolbar {
    display: grid;
    gap: 8px;
    padding: 8px;
  }

  .toolbar-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    padding: 0;
    border-right: none;
  }

  .toolbar-group.toolbar-end {
    margin-left: 0;
  }

  .btn-toolbar {
    padding: 4px 8px;
    font-size: 12px;
    width: 100%;
  }

  .editor-visual,
  .editor-code,
  .block-content {
    padding: 12px;
    font-size: 14px;
  }

  .tilda-blocks-panel {
    padding: 8px;
  }

  .blocks-list {
    flex-wrap: nowrap;
  }

  .block-btn {
    padding: 6px 8px;
    font-size: 11px;
    white-space: nowrap;
  }
}
