.template-designer-container {
  display: flex;
  flex-direction: column;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  background: #fff;
  overflow: hidden;
}

.template-designer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.toolbar-group {
  display: flex;
  gap: 0.125rem;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: #dee2e6;
  margin: 0 0.25rem;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  background: transparent;
  color: #495057;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

  .toolbar-btn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #dee2e6;
  }

  .toolbar-btn:active:not(:disabled) {
    background: #dee2e6;
  }

  .toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .toolbar-btn i {
    font-size: 1.125rem;
  }

.template-designer-content {
  flex: 1;
  min-height: 0;
}

  .template-designer-content iframe {
    display: block;
    border: none;
  }

    .template-designer-content iframe.disabled {
      pointer-events: none;
      opacity: 0.7;
    }

.source-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.source-textarea {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 1rem;
  background: #1e1e1e;
  color: #d4d4d4;
  resize: none;
}

  .source-textarea:focus {
    outline: none;
  }

  .source-textarea:disabled {
    opacity: 0.7;
    cursor: not-allowed;
  }

/* Table Dialog Styles */
.td-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
}

.td-dialog {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  min-width: 320px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.td-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid #dee2e6;
}

.td-dialog-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.td-dialog-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  line-height: 1;
}

.td-dialog-close:hover {
  color: #000;
}

.td-dialog-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.td-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid #dee2e6;
}

.td-form-group {
  margin-bottom: 1rem;
}

.td-form-label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.td-form-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  font-size: 1rem;
}

.td-form-input:focus {
  outline: none;
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.td-btn {
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.td-btn-primary {
  background: #0d6efd;
  color: #fff;
}

.td-btn-primary:hover {
  background: #0b5ed7;
}

.td-btn-secondary {
  background: #6c757d;
  color: #fff;
}

.td-btn-secondary:hover {
  background: #5c636a;
}

/* Image Picker Styles */
.td-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.td-image-item {
  position: relative;
  border: 2px solid transparent;
  border-radius: 0.5rem;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1;
  background: #f8f9fa;
}

.td-image-item:hover {
  border-color: #86b7fe;
}

.td-image-item.selected {
  border-color: #0d6efd;
}

.td-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.td-image-item-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.25rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.td-image-empty {
  text-align: center;
  padding: 2rem;
  color: #6c757d;
}

.td-image-loading {
  text-align: center;
  padding: 2rem;
}
