/* Base layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}
.lead {
  color: #475569;
}
.card {
  background: #fff;
  border: 1px solid #e6e9ef;
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}
.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.label {
  font-weight: 600;
}
.input {
  padding: 0.6rem 0.8rem;
  border: 1px solid #cfd6e6;
  border-radius: 10px;
  min-width: 240px;
}
.btn {
  padding: 0.6rem 0.9rem;
  border: none;
  border-radius: 10px;
  background: #1e40af;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover {
  filter: brightness(1.05);
}
.btn-outline {
  background: #fff;
  color: #1e40af;
  border: 1px solid #b5c0de;
}
.btn-secondary {
  background: #334155;
}
.btn-primary {
  background: #0f766e;
}
.btn-ghost {
  background: transparent;
  color: #1e293b;
  border: 1px solid transparent;
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
}
.btn-ghost:hover {
  border-color: #cbd5f5;
}
.msg {
  margin-left: 0.5rem;
  color: #0f766e;
}

/* Old table styles (kept in case you reuse) */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  border: 1px solid #e6e9ef;
  padding: 0.4rem;
  vertical-align: top;
}
.table input,
.table textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem;
  border: 1px solid #cfd6e6;
  border-radius: 6px;
}
.table textarea {
  min-height: 60px;
}

/* Admin toolbar */
.admin-toolbar {
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.editor-search {
  flex: 1;
  min-width: 180px;
}

/* Mode pill */
.mode-pill {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.mode-pill-viewer {
  background: #ecfeff;
  color: #0369a1;
  border-color: #bae6fd;
}
.mode-pill-editor {
  background: #eef2ff;
  color: #4f46e5;
  border-color: #c7d2fe;
}

/* Viewer cards */
.rule-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  background: #ffffff;
}
.rule-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.5rem;
}
.rule-section {
  margin-top: 0.4rem;
}
.rule-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.2rem;
}
.rule-list {
  background: #f8fafc;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
}
.updated-time {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #64748b;
}

/* Editor layout */
#editorSection {
  margin-top: 1rem;
}
#editorContainer {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.editor-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: #f9fafb;
}
.editor-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}
.editor-modality-id {
  font-size: 0.75rem;
  color: #6b7280;
}
.editor-modality-name {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}
.editor-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.editor-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

/* Editor fields */
.editor-field {
  border-radius: 8px;
  padding: 0.5rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}
.editor-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.editor-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
}

/* List items within a field (drag & drop) */
.field-items {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: #f9fafb;
  border-radius: 6px;
  padding: 0.25rem 0.3rem;
  border: 1px solid transparent;
}
.field-item.dragging {
  opacity: 0.7;
  border-color: #93c5fd;
  background: #eff6ff;
}
.drag-handle {
  cursor: grab;
  font-size: 0.9rem;
  color: #64748b;
  user-select: none;
}
.field-input {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 0.85rem;
}
.delete-item-btn {
  border-radius: 999px;
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  width: 1.7rem;
  height: 1.7rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.delete-item-btn:hover {
  background: #fecaca;
}
.add-item-btn {
  font-size: 0.8rem;
}

/* History panel */
.history-container {
  margin-top: 0.5rem;
  border-top: 1px dashed #e5e7eb;
  padding-top: 0.4rem;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  background: #f9fafb;
  font-size: 0.78rem;
}
.history-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  color: #4b5563;
}
.history-meta span:first-child {
  font-weight: 600;
}
.history-restore-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* Small helper text */
.small-hint {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.15rem;
}

/* AI button styling (just using base .btn) */
.ai-suggest-btn {
  background: #0f766e;
}
.ai-suggest-btn:hover {
  filter: brightness(1.05);
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .editor-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .editor-card-actions {
    align-self: stretch;
    justify-content: flex-start;
  }
}
