/* ============================================================
   CARPETPRO ADMIN — admin.css
   Full admin layout: sidebar, topbar, cards, tables, forms
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-w: 240px;
  --topbar-h: 60px;

  --c-bg: #f0f4f9;
  --c-surface: #ffffff;
  --c-border: #e2e8f0;
  --c-shadow: rgba(0, 0, 0, 0.06);

  --c-sidebar-bg: #1a1f2e;
  --c-sidebar-hover: #252c40;
  --c-sidebar-active: #2d3550;
  --c-sidebar-text: #a3abbe;
  --c-sidebar-head: #ffffff;

  --c-primary: #4f6ef7;
  --c-primary-dk: #3b5bdb;
  --c-success: #22c55e;
  --c-danger: #ef4444;
  --c-warning: #f59e0b;
  --c-info: #06b6d4;

  --c-text: #1e293b;
  --c-muted: #64748b;
  --c-label: #475569;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px var(--c-shadow);
  --shadow-md: 0 4px 16px var(--c-shadow);
}

html,
body {
  height: 100%;
  font-family: "Inter", sans-serif;
  color: var(--c-text);
  background: var(--c-bg);
}

a {
  color: var(--c-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button {
  cursor: pointer;
  font-family: inherit;
}
input,
select,
textarea {
  font-family: inherit;
}

/* ── Layout shell ─────────────────────────────────────────── */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--c-sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.admin-sidebar__logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-sidebar__logo span {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}
.admin-sidebar__logo .logo-icon {
  width: 34px;
  height: 34px;
  background: var(--c-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sidebar-section {
  padding: 18px 12px 6px;
}
.sidebar-section__title {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-sidebar-text);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 6px;
}

.sidebar-nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--c-sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background 0.15s,
    color 0.15s;
  margin-bottom: 2px;
}
.sidebar-nav__item:hover {
  background: var(--c-sidebar-hover);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav__item.active {
  background: var(--c-sidebar-active);
  color: #fff;
}
.sidebar-nav__item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* ── Main content area ────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* prevents flex child overflow */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Topbar ───────────────────────────────────────────────── */
.admin-topbar {
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.admin-topbar__breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--c-muted);
}
.admin-topbar__breadcrumb a {
  color: var(--c-muted);
}
.admin-topbar__breadcrumb a:hover {
  color: var(--c-text);
}
.admin-topbar__breadcrumb .sep {
  color: var(--c-border);
}
.admin-topbar__breadcrumb .current {
  color: var(--c-text);
  font-weight: 600;
}

.admin-topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Page content ─────────────────────────────────────────── */
.admin-content {
  padding: 28px;
  flex: 1;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-header__sub {
  font-size: 13px;
  color: var(--c-muted);
  margin-top: 2px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  transition:
    background 0.15s,
    transform 0.1s,
    box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
  text-decoration: none;
}
.btn:active {
  transform: none;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--c-primary-dk);
  color: #fff;
}
.btn-success {
  background: var(--c-success);
  color: #fff;
}
.btn-danger {
  background: var(--c-danger);
  color: #fff;
}
.btn-warning {
  background: var(--c-warning);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--c-muted);
  border: 1px solid var(--c-border);
}
.btn-ghost:hover {
  background: var(--c-bg);
  color: var(--c-text);
}
.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}
.btn-icon {
  padding: 7px;
  border-radius: 6px;
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}
.card-body {
  padding: 20px;
}
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--c-border);
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Data Table ───────────────────────────────────────────── */
.data-table-wrap {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  table-layout: fixed; /* columns share space evenly */
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th,
.data-table td {
  padding: 11px 16px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table thead tr {
  background: #f8fafc;
  border-bottom: 1px solid var(--c-border);
}
.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--c-muted);
  white-space: nowrap;
}
.data-table th a {
  color: var(--c-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.data-table th a:hover {
  color: var(--c-text);
  text-decoration: none;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--c-border);
  transition: background 0.1s;
}
.data-table tbody tr:last-child {
  border-bottom: none;
}
.data-table tbody tr:hover {
  background: #f8faff;
}
.data-table .actions {
  display: flex;
  gap: 6px;
}
.data-table .cell-number {
  font-variant-numeric: tabular-nums;
}
.data-table .cell-id {
  color: var(--c-muted);
  font-size: 12px;
}
.data-table .cell-ts {
  font-size: 12px;
  color: var(--c-muted);
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success {
  background: #dcfce7;
  color: #15803d;
}
.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}
.badge-warning {
  background: #fef3c7;
  color: #92400e;
}
.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}
.badge-neutral {
  background: #f1f5f9;
  color: #475569;
}

/* ── Search bar ───────────────────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border);
  background: #fafbfc;
}
.search-input {
  flex: 1;
  max-width: 300px;
  padding: 7px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.search-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--c-muted);
}
.pagination a,
.pagination span {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  transition: background 0.12s;
}
.pagination a:hover {
  background: var(--c-bg);
  text-decoration: none;
}
.pagination .active {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}
.pagination .disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group.full-width {
  grid-column: 1 / -1;
}
.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-label);
}
.form-label .required {
  color: var(--c-danger);
  margin-left: 2px;
}
.form-control {
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--c-text);
  background: #fff;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.form-control:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}
.form-control.is-invalid {
  border-color: var(--c-danger);
}
.form-hint {
  font-size: 11.5px;
  color: var(--c-muted);
}
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}
.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--c-primary);
}
.form-check label {
  font-size: 13.5px;
  color: var(--c-label);
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ── Flash messages ───────────────────────────────────────── */
.flash-container {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid;
  animation: slideIn 0.2s ease;
}
.flash-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}
.flash-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.flash__close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 16px;
  opacity: 0.5;
  cursor: pointer;
}
.flash__close:hover {
  opacity: 1;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Detail page ──────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0;
}
.detail-row {
  padding: 12px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detail-row:last-child {
  border-bottom: none;
}
.detail-key {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-muted);
}
.detail-value {
  font-size: 14px;
  color: var(--c-text);
  font-weight: 500;
}
.detail-value.mono {
  font-family: monospace;
}

.related-section {
  margin-top: 32px;
}
.related-section__header {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--c-text);
}

/* ── Dashboard stat cards ─────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  transition:
    box-shadow 0.15s,
    transform 0.15s;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}
.stat-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: rgba(79, 110, 247, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.stat-card__info {
  flex: 1;
}
.stat-card__label {
  font-size: 12px;
  color: var(--c-muted);
  font-weight: 500;
}
.stat-card__value {
  font-size: 24px;
  font-weight: 700;
  color: var(--c-text);
}
.stat-card__link {
  font-size: 11.5px;
  color: var(--c-primary);
  margin-top: 2px;
}

/* ── Confirmation modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-overlay.show .modal {
  transform: scale(1);
}
.modal__icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.modal__title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}
.modal__body {
  font-size: 13.5px;
  color: var(--c-muted);
  margin-bottom: 20px;
}
.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--c-muted);
}
.empty-state__icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.empty-state__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text);
}
.empty-state__text {
  font-size: 13px;
  margin-top: 4px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main {
    margin-left: 0;
  }
  .admin-content {
    padding: 16px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .db-explorer {
    flex-direction: column;
  }
  .db-table-list {
    width: 100%;
    max-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
  }
}

/* ── Database Explorer ──────────────────────────────────────────────────────── */

.db-explorer {
  display: flex;
  gap: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 560px;
}

/* Left panel */
.db-table-list {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  overflow: hidden;
}

.db-panel-header {
  padding: 14px 16px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.db-panel-count {
  background: var(--c-primary);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 7px;
  font-weight: 700;
  letter-spacing: 0;
}

.db-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
}

.db-search-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12.5px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--c-text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  font-family: inherit;
}
.db-search-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.db-table-items {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
}

.db-table-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--c-text);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
  border-radius: 0;
  user-select: none;
}
.db-table-item:hover {
  background: rgba(79, 110, 247, 0.07);
  color: var(--c-primary);
}
.db-table-item.active {
  background: rgba(79, 110, 247, 0.12);
  color: var(--c-primary);
  font-weight: 600;
}
.db-table-item__icon {
  font-size: 9px;
  color: var(--c-muted);
  transition: color 0.12s;
}
.db-table-item.active .db-table-item__icon,
.db-table-item:hover .db-table-item__icon {
  color: var(--c-primary);
}
.db-table-item__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12.5px;
}
.db-table-item__count {
  font-size: 11px;
  color: var(--c-muted);
  background: #f0f4f9;
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.db-table-item.active .db-table-item__count {
  background: rgba(79, 110, 247, 0.15);
  color: var(--c-primary);
}

/* Right panel */
.db-col-panel {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.db-col-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--c-muted);
  padding: 64px 20px;
}

.db-table-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.18s ease;
}
.db-table-detail.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.db-detail-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: #fafbfc;
  flex-shrink: 0;
}
.db-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
}
.db-detail-comment {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 3px;
}
.db-detail-meta {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
  padding-top: 3px;
}

/* Column detail table overrides */
.db-col-table {
  table-layout: auto;
}
.db-col-table th:nth-child(1),
.db-col-table td:nth-child(1) {
  width: 40px;
}
.db-col-table th:nth-child(4),
.db-col-table td:nth-child(4) {
  width: 90px;
}
.db-col-table th:nth-child(6),
.db-col-table td:nth-child(6) {
  width: 100px;
}
.db-col-table th:nth-child(7),
.db-col-table td:nth-child(7) {
  width: 180px;
}

.db-col-name {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 13px;
  font-weight: 500;
}
.db-col-name.db-col-pk {
  color: var(--c-primary);
  font-weight: 700;
}

.db-default-val code {
  font-family: monospace;
  font-size: 11.5px;
  color: var(--c-muted);
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
}

.db-constraint-badges {
  display: flex;
  gap: 4px;
}

.db-fk-ref {
  font-family: monospace;
  font-size: 11.5px;
  color: var(--c-info);
}

.db-extra-detail {
  white-space: nowrap;
}

/* Type badges */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  white-space: nowrap;
}
.type-badge-int {
  background: #e0e7ff;
  color: #3730a3;
}
.type-badge-float {
  background: #f0fdf4;
  color: #166534;
}
.type-badge-text {
  background: #fef3c7;
  color: #92400e;
}
.type-badge-ts {
  background: #f0f9ff;
  color: #0369a1;
}
.type-badge-bool {
  background: #fdf4ff;
  color: #7e22ce;
}
.type-badge-json {
  background: #fff7ed;
  color: #9a3412;
}
.type-badge-uuid {
  background: #f0fdf4;
  color: #065f46;
}
.type-badge-other {
  background: #f1f5f9;
  color: #475569;
}

/* ── Add Column Modal ───────────────────────────────────────────────────────── */

.ac-overlay {
  align-items: center;
  justify-content: center;
}

.ac-modal {
  width: 640px;
  max-width: 96vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 0;
  border-radius: var(--radius-lg);
}

.ac-modal__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--c-border);
  background: #fafbfc;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.ac-modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  flex: 1;
}
.ac-modal__table {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-primary);
  background: rgba(79, 110, 247, 0.1);
  padding: 2px 9px;
  border-radius: 4px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-modal__close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--c-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition:
    background 0.12s,
    color 0.12s;
}
.ac-modal__close:hover {
  background: var(--c-bg);
  color: var(--c-text);
}

.ac-modal__body {
  padding: 20px 22px;
}

.ac-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
  margin-top: 16px;
}

/* Form rows */
.ac-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ac-row--checks {
  align-items: center;
  gap: 20px;
  padding: 8px 0;
}

.ac-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
}
.ac-field--grow {
  flex: 1;
}
.ac-field--wide {
  flex: 1.4;
}
.ac-field--full {
  flex: 1 1 100%;
  width: 100%;
}

.ac-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-label);
}
.ac-req {
  color: var(--c-danger);
  margin-left: 2px;
}
.ac-hint {
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 2px;
}

/* Checkbox row */
.ac-check-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-label);
  cursor: pointer;
  user-select: none;
}
.ac-check-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--c-primary);
  cursor: pointer;
}

/* SQL preview */
.ac-preview {
  background: #0f172a;
  color: #e2e8f0;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12.5px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.6;
  min-height: 44px;
  border: 1px solid #1e293b;
}

/* Result feedback */
.ac-result {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}
.ac-result.hidden {
  display: none;
}
.ac-result--ok {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.ac-result--err {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  word-break: break-word;
}

/* ── New-column highlight (post-reload) ─────────────────────────────────────── */
@keyframes colPulse {
  0% {
    background: #bbf7d0;
    box-shadow: inset 0 0 0 2px #22c55e;
  }
  60% {
    background: #dcfce7;
    box-shadow: inset 0 0 0 2px #86efac;
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}
.col-highlight {
  animation: colPulse 3s ease forwards;
}

/* ── Column action buttons ───────────────────────────────────────────────────── */

.db-col-actions {
  width: 72px;
  padding: 6px 8px !important;
}

.col-action-btns {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

tr:hover .col-action-btns {
  opacity: 1;
}

.col-edit-btn:hover {
  background: rgba(79, 110, 247, 0.1) !important;
  color: var(--c-primary) !important;
}

.col-del-btn:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  color: var(--c-danger) !important;
}

/* ── Bulk actions bar ───────────────────────────────────────────────────────── */

.db-bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.3),
    0 8px 10px -6px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.db-bulk-bar.show {
  transform: translateX(-50%) translateY(0);
}

.db-bulk-count {
  font-weight: 600;
  font-size: 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  padding-right: 20px;
}

.db-bulk-actions {
  display: flex;
  gap: 12px;
}

.col-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--c-primary);
}

.db-col-table th:first-child,
.db-col-table td:first-child {
  padding-left: 20px !important;
  width: 40px;
}
