/* ═══════════════════════════════════════════════════════════════════════════
   ClavisDB – custom.css
   Only styles that cannot be achieved with Tailwind utility classes, or that
   are used inside user-defined form templates (where Tailwind won't purge).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── signature background ─────────────────────────────────────────────────────────── */
.clavisbg {
  /* background: linear-gradient(3deg,rgba(2, 0, 36, 1) 0%, rgba(9, 9, 121, 1) 35%, rgba(0, 212, 255, 1) 100%); */
  background: rgba(60, 130, 246, 1);
}

/* ── Sidebar tree ─────────────────────────────────────────────────────────── */
#sidebar.collapsed {
  width: 0;
  border-right-width: 0;
}

/* On narrow smartphone screens the sidebar becomes a full-screen overlay that
   slides in over the content and is hidden (off-canvas) by default. The width
   utility classes (w-64 / w-0) are overridden here — visibility is driven purely
   by the `.collapsed` class via a horizontal transform. */
@media (max-width: 639px) {
  #sidebar {
    position: fixed;
    top: 3rem;            /* below the fixed h-12 header */
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100%;
    z-index: 40;
    border-right-width: 0;
    transform: translateX(0);
  }
  #sidebar.collapsed {
    width: 100% !important;
    transform: translateX(-100%);
  }
}

/* ── Scrollbar styling ────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── List view table ──────────────────────────────────────────────────────── */
.list-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}
.list-table th,
.list-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.list-table th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 2;
}
.list-table .fixed-col {
  position: sticky;
  left: 0;
  z-index: 3;
  /* background: #b2c5ff; */
}
.list-table thead .fixed-col {
  z-index: 4;
  /* background: #fff; */
}
.list-table tbody tr:hover td {
  background: #eff6ff;
}
.list-table tbody tr:hover .fixed-col {
  background: #eff6ff;
}
.list-table tbody tr.selected td,
.list-table tbody tr.selected .fixed-col {
  background: #dbeafe;
}

/* ── Column type icons (inline svg as data-uri via CSS avoids purge) ──────── */
.col-type-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  vertical-align: middle;
  opacity: 0.6;
}

/* ── Dropdown menus ───────────────────────────────────────────────────────── */
.dropdown-menu {
  position: fixed;
  min-width: 160px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 100;
  padding: 4px 0;
}
.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px;
  font-size: 0.85rem;
  text-align: left;
  color: #374151;
  background: none;
  border: none;
  cursor: pointer;
}
.dropdown-menu button:hover {
  background: #f1f5f9;
}
.dropdown-menu button.danger {
  color: #dc2626;
}

/* ── Form template field styles (used by form.php + inline forms) ─────────── */
.form-template .field-wrapper { margin-bottom: 1.25rem; }
.form-template .field-label              { font-size: .875rem; font-weight: 500;
                                           margin-bottom: .35rem; color: #374151; }
.form-template .field-label:not(.flex)  { display: block; }
.form-template .field-label .req { color: #ef4444; }
.form-template .field-value { display: inline; }
.form-template .field-input   { display: block; width: 100%; padding: .5rem .75rem;
                                 border: 1px solid #d1d5db; border-radius: .5rem;
                                 font-size: .95rem; outline: none; color: #111827; }
.form-template .field-input:focus { border-color: #2563eb;
                                     box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-template .field-readonly { background: #f9fafb; color: #6b7280; cursor: not-allowed; }
.form-template textarea.field-input { min-height: 100px; resize: vertical; }
.form-template .field-checkbox { width: 1.25rem; height: 1.25rem; margin-top: .2rem; }
.form-template .field-checkbox-label { display: flex; align-items: flex-start; gap: .6rem; cursor: pointer; font-size: .875rem; font-weight: 500; color: #374151; line-height: 1.5; }
.form-template .field-label-error { color: #ef4444 !important; }
.form-template .field-input-invalid { border-color: #ef4444 !important; }
.form-template .field-input-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.form-template .field-verr { display: block; color: #ef4444; font-size: .8rem; margin-top: .3rem; }
.form-template .field-verr.hidden { display: none; }

/* ── Change log cells (list view + <changelog> form embeds) ───────────────── */
.cl-cell { max-width: 400px; white-space: normal; overflow-wrap: anywhere; }
.form-template #wf-submit { padding: .5rem 1.5rem; background: #2563eb; color: #fff; font-weight: 600; border-radius: .5rem; border: none; cursor: pointer; font-size: .9rem; }
.form-template #wf-submit:hover { background: #1d4ed8; }
.form-template #wf-submit:disabled { opacity: .6; cursor: not-allowed; }
.form-template .wf-error { color: #dc2626; padding: .75rem 1rem; background: #fef2f2; border: 1px solid #fecaca; border-radius: .5rem; font-size: .875rem; margin-bottom: 1rem; }
.form-template .wf-success { color: #15803d; padding: .75rem 1rem; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: .5rem; font-size: .875rem; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  font-size: 0.875rem;
  min-width: 240px;
  max-width: 380px;
  pointer-events: all;
  animation: toast-in .2s ease;
}
.toast-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.toast-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.toast-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }
.toast-warn    { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Animations ───────────────────────────────────────────────────────────── */
.fade-in  { animation: fade-in .15s ease; }
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Checkbox in list view ────────────────────────────────────────────────── */
.list-checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: #2563eb;
  cursor: pointer;
}

/* ── Pagination bar ───────────────────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.8rem;
  color: #64748b;
}
.pagination-bar button {
  padding: 3px 9px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
}
.pagination-bar button.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.pagination-bar button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── View editor drag-and-drop ────────────────────────────────────────────── */
#ve-tbody tr.ve-dragging { opacity: 0.4; }
#ve-tbody tr.ve-drag-over-top { box-shadow: 0 -2px 0 #2563eb; }
#ve-tbody tr.ve-drag-over-bot { box-shadow: 0 2px 0 #2563eb; }

/* ── Formula info tooltip ─────────────────────────────────────────────────── */
.formula-info-wrap { display: inline-flex; align-items: center; }
.formula-info-icon { width: 14px; height: 14px; color: #9ca3af; transition: color .15s; }
.formula-info-wrap:hover .formula-info-icon { color: #2563eb; }
.formula-tooltip {
  display: none;
  position: fixed;
  transform: translateX(-50%) translateY(-100%);
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.72rem;
  line-height: 1.5;
  z-index: 9999;
  min-width: 310px;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  white-space: nowrap;
}
.formula-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
}
.formula-tooltip .ft-head {
  color: #94a3b8; font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600; margin-top: 8px; margin-bottom: 3px;
}
.formula-tooltip .ft-head:first-child { margin-top: 0; }
.formula-tooltip .ft-row { display: flex; gap: 12px; margin-bottom: 2px; align-items: baseline; }
.formula-tooltip .ft-row code { color: #7dd3fc; min-width: 170px; font-size: 0.72rem; }
.formula-tooltip .ft-row span { color: #cbd5e1; }
.formula-tooltip .ft-eg { margin-bottom: 2px; }
.formula-tooltip .ft-eg code { color: #86efac; font-size: 0.72rem; }
