/* -----------------------------------------------------------
   TABLE EDITOR STYLES
   Styling für den visuellen Tabelleneditor
----------------------------------------------------------- */

/* Modal Backdrop */
.table-editor-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.table-editor-modal.hidden {
  display: none;
}

/* Dialog Container */
.table-editor-dialog {
  background: var(--preview-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  max-width: 900px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.table-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--tab-active);
}

.table-editor-header h2 {
  margin: 0;
  font-size: 18px;
}

.close-table-editor {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.close-table-editor:hover {
  background: var(--border);
  border-radius: 4px;
}

/* Body */
.table-editor-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Controls */
.table-controls {
  background: var(--tab-bg);
  padding: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.control-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.control-group label {
  font-weight: bold;
  min-width: 120px;
}

#tableSizeDisplay {
  font-family: monospace;
  background: var(--preview-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
}

.button-group {
  display: flex;
  gap: 8px;
  flex: 1;
}

.control-btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--preview-bg);
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

.control-btn:hover {
  background: var(--tab-active);
  transform: translateY(-1px);
}

.control-btn:active {
  transform: translateY(0);
}

/* Grid Input Wrapper */
.table-editor-grid-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-editor-grid-wrapper label {
  font-weight: bold;
  font-size: 14px;
}

/* Grid Container */
.table-editor-grid {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--tab-bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
}

/* Die Leiste der Spaltenausrichtung steht über der Kopfzelle;
   ihre Styles teilt sie mit dem Outline-Menü (style.css) */

/* Zellen-Input */
.table-cell {
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--preview-bg);
  color: var(--text);
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  transition: border-color 0.2s;
}

.table-cell:focus {
  outline: none;
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.table-cell.header-cell {
  font-weight: bold;
  background: var(--tab-active);
  border: 2px solid var(--border);
}

.ghost-cell {
  opacity: 0.4;
  border-style: dashed;
  font-style: italic;
}

.ghost-cell:focus {
  opacity: 1;
  border-style: solid;
  font-style: normal;
}

/* Preview Wrapper */
.table-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.table-preview-wrapper label {
  font-weight: bold;
  font-size: 14px;
}

/* Markdown Vorschau */
.table-preview {
  background: var(--tab-bg);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
  max-height: 180px;
  overflow-y: auto;
  margin: 0;
  color: var(--text);
}

/* HTML Vorschau */
.table-html-preview {
  background: var(--tab-bg);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 4px;
  font-size: 13px;
  max-height: 180px;
  overflow-y: auto;
}

.table-html-preview table {
  border-collapse: collapse;
  width: 100%;
}

.table-html-preview th,
.table-html-preview td {
  border: 1px solid var(--border);
  padding: 6px;
  text-align: left;
}

.table-html-preview th {
  background: var(--tab-active);
  font-weight: bold;
}

/* Footer */
.table-editor-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--tab-bg);
}

/* Die Fußzeilen-Buttons des Dialogs. Nur hier: dieselben Namen tragen in der
   Toolbar den Rang der Aktion (style.css), und ein Dialogknopf hat dort nichts
   zu suchen. */
.table-editor-modal .btn-primary,
.table-editor-modal .btn-secondary {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.table-editor-modal .btn-primary {
  background: #4a90e2;
  color: white;
  border-color: #4a90e2;
}

.table-editor-modal .btn-primary:hover {
  background: #357abd;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(74, 144, 226, 0.3);
}

.table-editor-modal .btn-secondary {
  background: var(--tab-bg);
  color: var(--text);
}

.table-editor-modal .btn-secondary:hover {
  background: var(--tab-active);
}

/* Responsive */
@media (max-width: 768px) {
  .table-editor-dialog {
    width: 95%;
    max-height: 90vh;
  }

  .table-editor-body {
    gap: 12px;
    padding: 12px;
  }

  .control-group {
    flex-direction: column;
    align-items: flex-start;
  }

  .button-group {
    flex-direction: column;
    width: 100%;
  }

  .control-btn {
    width: 100%;
  }

  .table-editor-grid {
    max-height: 200px;
  }

  .table-preview,
  .table-html-preview {
    max-height: 150px;
  }
}

/* Scrollbar Styling */
.table-editor-grid::-webkit-scrollbar,
.table-preview::-webkit-scrollbar,
.table-html-preview::-webkit-scrollbar {
  width: 8px;
}

.table-editor-grid::-webkit-scrollbar-track,
.table-preview::-webkit-scrollbar-track,
.table-html-preview::-webkit-scrollbar-track {
  background: var(--tab-bg);
  border-radius: 4px;
}

.table-editor-grid::-webkit-scrollbar-thumb,
.table-preview::-webkit-scrollbar-thumb,
.table-html-preview::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.table-editor-grid::-webkit-scrollbar-thumb:hover,
.table-preview::-webkit-scrollbar-thumb:hover,
.table-html-preview::-webkit-scrollbar-thumb:hover {
  background: #888;
}
