/* ============================================================
   LamDB - Custom Styles
   Uses Tailwind for utility classes + these custom components
   ============================================================ */

/* ---- Branding-Variablen (Fallback-Defaults, werden per PHP überschrieben) -- */
:root {
  --ldb-primary:         var(--ldb-primary);
  --ldb-primary-dark:    var(--ldb-primary-dark);
  --ldb-primary-light:   var(--ldb-primary-light);
  --ldb-primary-bg:      var(--ldb-primary-bg);
  --ldb-primary-bg-hover:var(--ldb-primary-bg-hover);
  --ldb-primary-darkest: var(--ldb-primary-darkest);
  --ldb-primary-text:    var(--ldb-primary-text);
  --ldb-app-bg:          #f8fafc;
  --ldb-login-bg:        #f1f5f9;
  --ldb-login-bg-end:    #eef5f8;
}

/* ---- Shared semantic classes (used across pages) --------------------------- */
.ldb-body          { background: var(--ldb-app-bg); }
.ldb-nav           { background: #fff; border-bottom: 1px solid #e2e8f0; }
.ldb-card          { background: #fff; border: 1px solid #e2e8f0; border-radius: 0.75rem; }
.ldb-text-primary  { color: #1e293b; }
.ldb-text-muted    { color: #64748b; }
.ldb-nav-link      { display:flex; align-items:center; gap:6px; font-size:0.875rem; color:#475569; padding:6px 12px; border-radius:8px; cursor:pointer; background:none; border:none; text-decoration:none; transition:background 0.1s, color 0.1s; }
.ldb-nav-link:hover { background:#f1f5f9; color:#0f172a; }
.activity-change-pill { display:inline-flex; align-items:center; gap:4px; background:#f8fafc; border:1px solid #e2e8f0; border-radius:6px; padding:2px 8px; font-size:0.75rem; }

/* ============================================================
   Dark Mode
   ============================================================ */
.dark .ldb-body,
.dark body                       { background: #0f172a !important; color: #cbd5e1; }
.dark .ldb-nav,
.dark nav.ldb-nav                { background: #1e293b !important; border-bottom-color: #334155 !important; }
.dark .ldb-card                  { background: #1e293b !important; border-color: #334155 !important; }
.dark .ldb-text-primary          { color: #e2e8f0 !important; }
.dark .ldb-text-muted            { color: #94a3b8 !important; }
.dark .ldb-nav-link              { color: #94a3b8; }
.dark .ldb-nav-link:hover        { background: #334155; color: #e2e8f0; }
.dark .activity-change-pill      { background: #334155; border-color: #475569; }

/* Hintergründe */
.dark .bg-white    { background: #1e293b !important; }
.dark .bg-slate-50 { background: #0f172a !important; }
.dark .bg-slate-100{ background: #1e293b !important; }
.dark .bg-slate-200{ background: #334155 !important; }
.dark .bg-teal-50{ background: #003d47 !important; }

/* Text */
.dark .text-slate-800, .dark .text-slate-900 { color: #e2e8f0 !important; }
.dark .text-slate-700                         { color: #cbd5e1 !important; }
.dark .text-slate-600, .dark .text-slate-500  { color: #94a3b8 !important; }
.dark .text-slate-400                         { color: #64748b !important; }
.dark .font-bold.text-slate-800               { color: #f1f5f9 !important; }

/* Ränder */
.dark .border-slate-200 { border-color: #334155 !important; }
.dark .border-slate-100 { border-color: #1e293b !important; }
.dark .divide-slate-200 > * + * { border-color: #334155 !important; }

/* Nav */
.dark nav { background: #1e293b; border-bottom-color: #334155; }
.dark .nav-dropdown { background: #1e293b; border-color: #334155; }
.dark .nav-dropdown a:hover { background: #334155; }

/* Grid / Tabelle */
.dark .ldb-grid th { background: #1e293b; border-color: #334155; color: #94a3b8; }
.dark .ldb-grid td { border-color: #1e293b; color: #cbd5e1; }
.dark .ldb-grid tr:hover td { background: #334155 !important; }
.dark .ldb-grid tr.selected td { background: #1e1b4b !important; }
.dark .grid-header-row { background: #1e293b; border-color: #334155; }
.dark .col-resizer { background: #475569; }

/* Inputs */
.dark .ldb-input {
  background: #0f172a !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}
.dark .ldb-input:focus {
  border-color: var(--ldb-primary) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25) !important;
}
.dark input[type="text"], .dark input[type="date"], .dark input[type="datetime-local"],
.dark input[type="number"], .dark input[type="email"], .dark input[type="time"],
.dark input[type="url"], .dark input[type="tel"],
.dark select, .dark textarea {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}
.dark input::placeholder, .dark textarea::placeholder { color: #475569; }

/* Buttons */
.dark .ldb-btn-secondary {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #cbd5e1 !important;
}
.dark .ldb-btn-secondary:hover { background: #334155 !important; }

/* Modals */
.dark .modal-overlay  { background: rgba(0,0,0,0.7) !important; }
.dark .modal-box      { background: #1e293b !important; border-color: #334155; }
.dark .modal-header   { border-bottom-color: #334155 !important; background: #1e293b !important; }
.dark .modal-footer   { border-top-color: #334155 !important; background: #1e293b !important; }

/* Floating panels */
.dark .floating-panel { background: #1e293b !important; border-color: #334155 !important; }
.dark .panel-section  { border-color: #334155 !important; }

/* Toolbar */
.dark .toolbar        { background: #1e293b !important; border-bottom-color: #334155 !important; }
.dark .toolbar-tab, .dark .view-tab { color: #94a3b8 !important; }
.dark .toolbar-tab.active, .dark .view-tab.active { color: var(--ldb-primary-light) !important; border-color: var(--ldb-primary-light) !important; }

/* Status bar */
.dark .status-bar { background: #1e293b !important; border-top-color: #334155 !important; color: #94a3b8 !important; }

/* Expand-row Tabs */
.dark .expand-tabs-bar  { background: #1e293b !important; border-bottom-color: #334155 !important; }
.dark .expand-tab        { color: #94a3b8 !important; }
.dark .expand-tab.active { color: var(--ldb-primary-light) !important; border-bottom-color: var(--ldb-primary-light) !important; }

/* Kommentare */
.dark .comment-input-area    { background: #0f172a !important; border-top-color: #334155 !important; }
.dark .comment-textarea      { background: #0f172a !important; border-color: #475569 !important; color: #e2e8f0 !important; }
.dark .comment-textarea:focus{ border-color: var(--ldb-primary) !important; }
.dark .comment-text          { color: #cbd5e1 !important; }
.dark .comment-author        { color: #e2e8f0 !important; }
.dark .comment-action-btn    { color: #64748b !important; }
.dark .comment-action-btn:hover { background: #334155 !important; color: #94a3b8 !important; }
.dark .mention-dropdown      { background: #1e293b !important; border-color: #334155 !important; }
.dark .mention-item:hover, .dark .mention-item.active { background: var(--ldb-primary-darkest) !important; }
.dark .comment-reply::before { border-color: #334155 !important; }

/* Aktivität */
.dark .activity-change-row { background: #0f172a !important; border-color: #334155 !important; }
.dark .activity-field-name { color: #94a3b8 !important; }

/* Dashboard-Karten */
.dark .base-card, .dark [class*="rounded-xl"][class*="border"] {
  background: #1e293b;
  border-color: #334155;
}
.dark .hover\:shadow-md:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important; }

/* Select-Chips */
.dark .select-chip { opacity: 0.9; }

/* Scrollbar (Webkit) */
.dark ::-webkit-scrollbar       { width: 6px; height: 6px; }
.dark ::-webkit-scrollbar-track { background: #0f172a; }
.dark ::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ---- Grid ----------------------------------------------------------------- */
.ldb-grid {
  border-collapse: collapse;
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
  font-size: 0.8125rem; /* 13px */
}

.ldb-grid th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  font-weight: 600;
  color: #475569;
  user-select: none;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
}

.ldb-grid td {
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  overflow: hidden;
  vertical-align: top;
  position: relative;
}

.ldb-grid td.editing {
  outline: 2px solid var(--ldb-primary);
  outline-offset: -2px;
  overflow: visible;
  z-index: 5;
}

.ldb-grid tr:hover td {
  background-color: #f8fafc;
}

.ldb-grid tr.selected td {
  background-color: var(--ldb-primary-bg);
}

/* Row height variants */
.row-short td   { height: 32px;  }
.row-medium td  { height: 56px;  }
.row-tall td    { height: 96px;  }

/* Column header */
.col-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: 100%;
  cursor: pointer;
}

.col-header:hover .col-menu-trigger {
  opacity: 1;
}

.col-menu-trigger {
  opacity: 0;
  transition: opacity 0.1s;
  padding: 2px 4px;
  border-radius: 4px;
  color: #94a3b8;
  cursor: pointer;
  flex-shrink: 0;
}

.col-menu-trigger:hover {
  background: #e2e8f0;
  color: #475569;
}

/* Row number column */
.col-row-num {
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.75rem;
}

/* System ID column */
.col-id-system {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  text-align: right;
  color: #94a3b8;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  padding-right: 12px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
}
.col-id-system .col-header {
  justify-content: flex-end;
}
.cell-id-system {
  user-select: none;
  cursor: default;
}

/* Checkbox column */
.col-check {
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  text-align: center;
}

/* Cell content */
.cell-content {
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: flex-start;
  padding-top: 6px;
  gap: 4px;
  overflow: hidden;
  cursor: default;
}

.cell-content .cell-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e293b;
}

/* Cell editor (inline) */
.cell-editor {
  position: absolute;
  inset: 0;
  border: none;
  outline: none;
  padding: 6px 8px;
  font-size: 0.8125rem;
  font-family: inherit;
  background: #fff;
  resize: none;
  width: 100%;
  z-index: 20;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.cell-editor-wrap {
  position: fixed;
  background: #fff;
  border: 2px solid var(--ldb-primary);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 240px;
  min-height: 120px;
  resize: both;
  overflow: auto;
}

.cell-editor-wrap textarea {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 8px;
  font-size: 0.8125rem;
  font-family: inherit;
  resize: none;
  background: transparent;
}

/* Expand row button */
.row-expand-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  padding: 2px 5px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.6875rem;
  color: #64748b;
  cursor: pointer;
  transition: opacity 0.1s;
  z-index: 5;
  line-height: 1;
}

tr:hover .row-expand-btn {
  opacity: 1;
}

.row-expand-btn:hover {
  background: #f8fafc;
  color: var(--ldb-primary);
  border-color: var(--ldb-primary);
}

/* Add column button */
.btn-add-col {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 12px;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  z-index: 10;
  font-size: 0.75rem;
  transition: background 0.1s, color 0.1s;
  height: 36px;
  vertical-align: middle;
}

.btn-add-col:hover {
  background: var(--ldb-primary-bg-hover);
  color: var(--ldb-primary);
}

/* Add row button */
.btn-add-row {
  background: transparent;
  color: #94a3b8;
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  padding: 6px 16px;
  border-top: 1px solid #f1f5f9;
  transition: background 0.1s, color 0.1s;
}

.btn-add-row:hover {
  background: #f8fafc;
  color: var(--ldb-primary);
}

/* Select/Multiselect chips */
.select-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Checkbox cell */
.cell-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--ldb-primary);
}

/* Rating stars */
.rating-star {
  color: #fbbf24;
  font-size: 0.875rem;
}
.rating-star.empty {
  color: #e2e8f0;
}

/* ---- Toolbar -------------------------------------------------------------- */
.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: #475569;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
  border: 1px solid transparent;
}

.toolbar-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.toolbar-btn.active {
  background: var(--ldb-primary-bg);
  color: var(--ldb-primary);
  border-color: #c7d2fe;
}

/* ---- Panels --------------------------------------------------------------- */
.panel {
  position: fixed;
  z-index: 300;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.13);
  min-width: 320px;
  max-height: 480px;
  overflow-y: auto;
  animation: slideDown 0.15s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

#panel-filter { min-width: 520px; }
#panel-sort   { min-width: 380px; }
#panel-fields { min-width: 260px; }

/* Inline search bar (below toolbar) */
.search-bar { flex-shrink: 0; }

/* ---- Modals --------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-box {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: #94a3b8;
  transition: background 0.1s, color 0.1s;
}

.modal-close-btn:hover {
  background: #f1f5f9;
  color: #475569;
}

/* ---- Buttons -------------------------------------------------------------- */
.ldb-btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  background: var(--ldb-primary);
  color: white;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.1s;
}
.ldb-btn-primary:hover { background: var(--ldb-primary-text); }
.ldb-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.ldb-btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  background: white;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.1s, border-color 0.1s;
}
.ldb-btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }

.ldb-btn-danger {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  background: white;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.1s;
}
.ldb-btn-danger:hover { background: #fef2f2; }

/* ---- Inputs --------------------------------------------------------------- */
.ldb-input {
  display: block;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.875rem;
  color: #1e293b;
  background: white;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.ldb-input:focus {
  outline: none;
  border-color: var(--ldb-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

select.ldb-input { cursor: pointer; }

/* ---- Dropdowns ------------------------------------------------------------ */
.nav-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 100;
  padding: 4px;
  max-height: 320px;
  overflow-y: auto;
  animation: dropIn 0.1s ease-out;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: #374151;
  text-align: left;
  transition: background 0.1s;
}
.dropdown-item:hover { background: #f8fafc; }

/* ---- Column context menu -------------------------------------------------- */
.col-menu {
  position: fixed;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 200;
  padding: 4px;
  min-width: 160px;
  animation: dropIn 0.1s ease-out;
}

.col-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: #374151;
  text-align: left;
  transition: background 0.1s;
}
.col-menu-item:hover { background: #f8fafc; }

/* ---- Import tabs ---------------------------------------------------------- */
.import-tab {
  padding: 5px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  border: 1px solid #e2e8f0;
  transition: all 0.1s;
}
.import-tab.active {
  background: var(--ldb-primary);
  color: white;
  border-color: var(--ldb-primary);
}

/* ---- Row height options --------------------------------------------------- */
.row-height-opt {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: #374151;
  text-align: left;
  transition: background 0.1s;
}
.row-height-opt:hover { background: #f8fafc; }
.row-height-opt.active { color: var(--ldb-primary); font-weight: 600; }

/* ---- Toast --------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  animation: toastIn 0.2s ease-out;
  max-width: 360px;
}

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

.toast-success { background: #1e293b; color: white; }
.toast-error   { background: #dc2626; color: white; }

/* ---- Column resizer ------------------------------------------------------- */
.col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  z-index: 11;
}
.col-resizer:hover, .col-resizer.resizing {
  background: var(--ldb-primary);
}

/* ---- Misc ----------------------------------------------------------------- */
.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-logic-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--ldb-primary);
  background: var(--ldb-primary-bg);
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 36px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.sort-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-visibility-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

/* 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; }

/* ---- Form View ------------------------------------------------------------ */
.form-view-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.form-view-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.form-view-nav-info {
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 500;
}

.form-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.8125rem;
  color: #475569;
  border: 1px solid #e2e8f0;
  background: white;
  transition: all 0.1s;
}
.form-nav-btn:hover:not(:disabled) { background: #f1f5f9; border-color: #cbd5e1; }
.form-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.form-view-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.form-view-body {
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-view-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-view-field.full-width {
  grid-column: 1 / -1;
}

.form-view-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-view-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid #f1f5f9;
  background: #fafafa;
}

/* ---- Form Options Panel --------------------------------------------------- */
.form-options-panel {
  width: 280px;
  min-width: 280px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.form-options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.form-options-body {
  flex: 1;
  overflow-y: auto;
}
.form-opts-section {
  border-bottom: 1px solid #f1f5f9;
}
.form-opts-section-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.07em;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
}
.form-opts-section-hdr:hover { background: #f8fafc; }
.form-opts-chevron { font-size: 9px; transition: transform 0.15s; }
.form-opts-section-body { padding-top: 0; }

/* Toggle switch (reusable) */
.ldb-toggle {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: #cbd5e1;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.ldb-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.ldb-toggle--on,
.ldb-toggle[aria-checked="true"] { background: var(--ldb-primary); }
.ldb-toggle--on::after,
.ldb-toggle[aria-checked="true"]::after { transform: translateX(14px); }

.ldb-toggle-sm {
  position: relative;
  width: 26px;
  height: 15px;
  border-radius: 8px;
  background: #cbd5e1;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.ldb-toggle-sm::after {
  content: '';
  position: absolute;
  top: 1.5px;
  left: 1.5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Dark mode */
.dark .form-options-panel { background: #1e293b; border-left-color: #334155; }
.dark .form-options-header { border-bottom-color: #334155; }
.dark .form-opts-section { border-bottom-color: #334155; }
.dark .form-opts-section-hdr { color: #64748b; }
.dark .form-opts-section-hdr:hover { background: #334155; }

/* New view type picker cards */
.view-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  gap: 2px;
  user-select: none;
}
.view-type-card:hover { border-color: #a5b4fc; background: #f5f3ff; }
.view-type-card.selected { border-color: var(--ldb-primary); background: var(--ldb-primary-bg); }

/* Responsive sidebar toggle */
@media (max-width: 768px) {
  .modal-box { max-width: 100%; border-radius: 16px 16px 0 0; margin: auto 0 0; max-height: 85vh; }
  .modal-overlay { align-items: flex-end; }
}

/* Sidebar collapsible */
#sidebar.sidebar-closed { width: 0 !important; border-right: none; }
#sidebar .sidebar-label { white-space: nowrap; }

/* View context menu */
.view-ctx-menu {
  position: fixed;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 200px;
  z-index: 1000;
  padding: 4px;
}
.view-ctx-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  font-size: 0.8125rem;
  color: #374151;
  border-radius: 5px;
  transition: background 0.1s;
}
.view-ctx-item:hover { background: #f1f5f9; }

/* ---- Link / Relation fields ----------------------------------------------- */
.link-chip {
  display: inline-flex;
  align-items: center;
  background: var(--ldb-primary-bg);
  color: var(--ldb-primary-text);
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-count-badge {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  cursor: pointer;
}
.link-count-badge--filled {
  background: var(--ldb-primary-bg);
  color: var(--ldb-primary-text);
  border-color: #c7d2fe;
}
.link-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: var(--ldb-primary);
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  background: var(--ldb-primary-bg);
  cursor: pointer;
  transition: background 0.1s;
}
.link-add-btn:hover { background: var(--ldb-primary-bg-hover); }
.link-expand-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---- Form link accordion -------------------------------------------------- */
.form-link-accordion-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 4px;
  overflow: hidden;
  background: white;
}
.form-link-accordion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  background: #f8fafc;
  transition: background 0.12s;
}
.form-link-accordion-header:hover { background: #f1f5f9; }
.form-link-accordion-body {
  border-top: 1px solid #f1f5f9;
  padding: 12px;
  background: white;
}
.form-link-accordion-loading {
  text-align: center;
  padding: 8px;
}
.accordion-form-fields { display: flex; flex-direction: column; gap: 8px; }
.accordion-form-row { display: flex; flex-direction: column; gap: 3px; }
.accordion-form-label { font-size: 0.75rem; font-weight: 500; color: #64748b; }
.accordion-form-value { font-size: 0.8125rem; color: #334155; padding: 4px 0; }
.accordion-form-footer { display: flex; justify-content: flex-end; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f1f5f9; }
.form-link-chevron { transition: transform 0.15s ease; }
.form-link-chevron.rotate-90 { transform: rotate(90deg); }

/* ---- Row expand as right-side drawer (NocoDB style) ----------------------- */
#modal-row-expand {
  align-items: flex-start;
  justify-content: flex-end;
  padding: 0;
  background: rgba(15, 23, 42, 0.3);
}
#modal-row-expand .modal-box {
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border-left: 1px solid #e2e8f0;
  max-width: 600px;
  animation: slideInRight 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
#row-expand-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0.4; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---- Details Panel -------------------------------------------------------- */
#details-panel {
  display: flex;
  flex-direction: column;
}
#details-panel.hidden { display: none; }
.dtab {
  background: transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.dtab-active {
  border-bottom-color: var(--ldb-primary) !important;
  color: var(--ldb-primary-text) !important;
}

/* ---- Data/Details nav tabs ------------------------------------------------ */
#tab-data, #tab-details {
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

/* ---- Toolbar button active states (filter = green tint, sort = orange) ---- */
#btn-filter.active, .toolbar-btn[data-panel="filter"].active {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
}
#btn-sort.active, .toolbar-btn[data-panel="sort"].active {
  background: #fff7ed;
  color: #ea580c;
  border-color: #fed7aa;
}

/* ---- Grid td cursor pointer on hover -------------------------------------- */
.ldb-grid td:hover {
  cursor: pointer;
}

/* ---- Form view card improvements ----------------------------------------- */
.form-view-card {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s;
}
.form-view-label {
  transition: color 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-view-field:focus-within .form-view-label {
  color: var(--ldb-primary);
}
.form-view-field input, .form-view-field textarea, .form-view-field select {
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* ---- Link chip & count badge improvements (NocoDB style) ------------------ */
.link-chip {
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--ldb-primary-bg);
  color: var(--ldb-primary-text);
  border: 1px solid #c7d2fe;
  transition: background 0.1s;
}
.link-chip:hover {
  background: var(--ldb-primary-bg-hover);
}
.link-count-badge {
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: background 0.1s;
}

/* ---- Select chip improvements --------------------------------------------- */
.select-chip {
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 9px;
  letter-spacing: 0.01em;
}

/* ============================================================
   Expand-Row Tabs (Felder / Kommentare / Aktivität)
   ============================================================ */

.expand-tabs-bar {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

.expand-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #64748b;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.expand-tab:hover {
  color: #334155;
}

.expand-tab.active {
  color: var(--ldb-primary);
  border-bottom-color: var(--ldb-primary);
  font-weight: 600;
}

.expand-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 700;
  background: var(--ldb-primary);
  color: #fff;
  line-height: 1;
}

/* ============================================================
   Kommentare
   ============================================================ */

#row-expand-comments {
  flex-direction: column;
}

#comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.comment-input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

.comment-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ldb-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.comment-input-inner {
  flex: 1;
  position: relative;
}

.comment-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  background: #fff;
  transition: border-color 0.15s;
  font-family: inherit;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--ldb-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Comment item */
.comment-item {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.comment-reply {
  margin-left: 40px;
  margin-top: -8px;
  padding-top: 12px;
  position: relative;
}

.comment-reply::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 0;
  bottom: 50%;
  width: 14px;
  border-left: 2px solid #e2e8f0;
  border-bottom: 2px solid #e2e8f0;
  border-bottom-left-radius: 6px;
}

.comment-avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-author {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e293b;
}

.comment-time {
  font-size: 0.6875rem;
  color: #94a3b8;
}

.comment-edited {
  font-size: 0.6875rem;
  color: #94a3b8;
  font-style: italic;
}

.comment-text {
  font-size: 0.8125rem;
  color: #334155;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-mention {
  color: var(--ldb-primary);
  font-weight: 600;
  background: var(--ldb-primary-bg);
  padding: 0 3px;
  border-radius: 4px;
}

.comment-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
  opacity: 0;
  transition: opacity 0.15s;
}

.comment-item:hover .comment-actions,
.comment-reply:hover .comment-actions {
  opacity: 1;
}

.comment-action-btn {
  font-size: 0.6875rem;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
}

.comment-action-btn:hover {
  background: #f1f5f9;
  color: #475569;
}

/* @-Mention Dropdown */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 4px;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: #334155;
  transition: background 0.1s;
}

.mention-item:hover,
.mention-item.active {
  background: var(--ldb-primary-bg);
  color: var(--ldb-primary);
}

.mention-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================================
   Aktivitäts-Feed
   ============================================================ */

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 5px;
}

.activity-user {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e293b;
}

.activity-verb {
  font-size: 0.8125rem;
  font-weight: 500;
}

.activity-time {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-left: auto;
}

.activity-changes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.activity-change-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 8px;
}

.activity-field-name {
  font-weight: 600;
  color: #475569;
  min-width: 80px;
}

.activity-old {
  color: #ef4444;
  background: #fef2f2;
  padding: 1px 5px;
  border-radius: 3px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-new {
  color: #16a34a;
  background: #f0fdf4;
  padding: 1px 5px;
  border-radius: 3px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   App Shell — Sidebar-Layout (seit v4.2)
   ============================================================ */

/* Body als Flex-Container für das gesamte Layout */
body.ldb-app {
  height: 100vh;
  overflow: hidden;
  display: flex;
  background: #f8fafc;
}

/* ---- Icon-Bar ---- */
.ldb-iconbar {
  width: 44px;
  background: #f1f5f9;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  flex-shrink: 0;
  overflow: visible;
}

.ldb-icon-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-bottom: 6px;
  text-decoration: none;
  flex-shrink: 0;
}

.ldb-icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  border: none;
  background: none;
  text-decoration: none;
  position: relative;
  flex-shrink: 0;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.ldb-icon-btn:hover { background: #e2e8f0; color: #1e293b; }
.ldb-icon-btn.active { background: var(--ldb-primary-bg-hover); color: var(--ldb-primary); }

.ldb-icon-spacer { flex: 1; min-height: 8px; }

.ldb-update-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid #f1f5f9;
  pointer-events: none;
}

/* ---- Panel ---- */
.ldb-panel {
  width: 240px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
  flex-shrink: 0;
}
.ldb-panel.ldb-panel--closed {
  width: 0;
}

.ldb-panel-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.ldb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 8px 12px;
  flex-shrink: 0;
}
.ldb-panel-header span {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ldb-panel-close {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.ldb-panel-close:hover { background: #f1f5f9; color: #475569; }

/* Base groups */
.ldb-base-header-row {
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: background 0.1s;
  position: relative;
}
.ldb-base-header-row:hover { background: #f8fafc; }
.ldb-base-header-row:hover .ldb-base-menu-btn { opacity: 1; }

.ldb-base-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 4px 4px 4px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.ldb-base-menu-btn {
  opacity: 0;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.ldb-base-menu-btn:hover { background: #e2e8f0; color: #475569; }

/* Inline rename input (used in sidebar for bases and views) */
.ldb-inline-rename-input {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--ldb-primary);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: inherit;
  font-weight: inherit;
  color: #1e293b;
  outline: none;
  letter-spacing: inherit;
  text-transform: inherit;
}

.ldb-table-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 22px;
  font-size: 0.8125rem;
  color: #475569;
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 4px;
  transition: background 0.1s, color 0.1s;
}
.ldb-table-item:hover { background: #f1f5f9; color: #1e293b; }
.ldb-table-item.active { background: var(--ldb-primary-bg-hover); color: var(--ldb-primary-text); font-weight: 500; }

/* View items inside table */
.ldb-views-list { padding-bottom: 2px; }
.ldb-view-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 36px;
  font-size: 0.75rem;
  color: #64748b;
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 4px;
  transition: background 0.1s, color 0.1s;
  position: relative;
}
.ldb-view-item:hover { background: #f1f5f9; color: #1e293b; }
.ldb-view-item.active { background: #ede9fe; color: #5b21b6; font-weight: 500; }
.ldb-view-item .ldb-view-menu-btn {
  margin-left: auto;
  opacity: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 11px;
  flex-shrink: 0;
}
.ldb-view-item:hover .ldb-view-menu-btn { opacity: 1; }
.ldb-view-item .ldb-view-menu-btn:hover { background: #e2e8f0; color: #475569; }

/* „Neue Tabelle"-Button im Panel (Tabellenebene, farbig hervorgehoben) */
.ldb-new-table-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 22px;
  font-size: 0.8125rem;
  font-weight: 400;
  font-family: inherit;
  color: var(--ldb-primary);
  border: none;
  background: transparent;
  border-radius: 6px;
  margin: 1px 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.1s, color 0.1s;
}
.ldb-new-table-btn:hover {
  background: var(--ldb-primary-bg);
  color: var(--ldb-primary-dark);
}

/* Admin panel items */
.ldb-panel-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: #475569;
  text-decoration: none;
  border-radius: 8px;
  margin: 1px 4px;
  transition: background 0.1s, color 0.1s;
}
.ldb-panel-item:hover { background: #f1f5f9; color: #1e293b; }
.ldb-panel-item.active { background: var(--ldb-primary-bg-hover); color: var(--ldb-primary-text); font-weight: 500; }
.ldb-panel-item .ldb-panel-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--ldb-primary-bg-hover);
  color: var(--ldb-primary-text);
  padding: 1px 6px;
  border-radius: 10px;
}

/* Panel footer */
.ldb-panel-footer {
  padding: 8px 12px;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

/* User menu popup */
.ldb-user-menu {
  position: absolute;
  bottom: 0;
  left: calc(100% + 8px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  width: 210px;
  z-index: 60;
  overflow: hidden;
}

/* Main content */
#ldb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  position: relative;
}

/* Suppress panel transition on initial page load (no-anim class set in <head> script) */
html.ldb-no-panel-anim #ldb-panel { transition: none !important; width: 0 !important; }
html.ldb-no-panel-anim #ldb-panel-open-btn { display: flex !important; }

/* Panel-Expand-Button (erscheint wenn Panel zugeklappt) — fixed links, unterhalb der Topbar */
#ldb-panel-open-btn {
  position: fixed;
  top: 86px;
  left: 44px;
  z-index: 200;
  width: 20px;
  height: 40px;
  border-radius: 0 6px 6px 0;
  border: 1px solid #e2e8f0;
  border-left: none;
  background: #fff;
  color: #64748b;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-size: 10px;
  box-shadow: 2px 0 6px rgba(0,0,0,0.06);
}
#ldb-panel-open-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.dark #ldb-panel-open-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
  border-left: none;
}
.dark #ldb-panel-open-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

/* Mobile header (only visible on small screens) */
.ldb-mobile-header {
  display: none;
  height: 48px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  flex-shrink: 0;
}

/* ---- Responsive ---- */
@media (max-width: 767px) {
  #ldb-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 40;
    background: #f1f5f9;
  }
  #ldb-sidebar.ldb-sidebar--mobile-open {
    transform: translateX(0);
  }
  .ldb-mobile-header { display: flex; }
}

/* ---- Dark Mode — Sidebar ---- */
.dark .ldb-iconbar {
  background: #1a2035;
  border-right-color: #2d3748;
}
.dark .ldb-icon-btn { color: #64748b; }
.dark .ldb-icon-btn:hover { background: #2d3748; color: #e2e8f0; }
.dark .ldb-icon-btn.active { background: var(--ldb-primary-darkest); color: var(--ldb-primary-light); }
.dark .ldb-update-dot { border-color: #1a2035; }

.dark .ldb-panel { background: #1e293b; border-right-color: #334155; }
.dark .ldb-panel-close:hover { background: #334155; color: #94a3b8; }
.dark .ldb-base-header { color: #64748b; }
.dark .ldb-base-header-row:hover { background: #334155; }
.dark .ldb-base-menu-btn { color: #475569; }
.dark .ldb-base-menu-btn:hover { background: #475569; color: #e2e8f0; }
.dark .ldb-inline-rename-input { background: #0f172a; color: #e2e8f0; }
.dark .ldb-table-item { color: #94a3b8; }
.dark .ldb-table-item:hover { background: #334155; color: #e2e8f0; }
.dark .ldb-table-item.active { background: var(--ldb-primary-darkest); color: #a5b4fc; }
.dark .ldb-view-item { color: #64748b; }
.dark .ldb-view-item:hover { background: #334155; color: #e2e8f0; }
.dark .ldb-view-item.active { background: #2e1065; color: #c4b5fd; }
.dark .ldb-view-item .ldb-view-menu-btn:hover { background: #475569; }
.dark .ldb-new-table-btn { color: var(--ldb-primary-light); }
.dark .ldb-new-table-btn:hover { background: var(--ldb-primary-darkest); color: var(--ldb-primary-light); }
.dark .ldb-panel-item { color: #94a3b8; }
.dark .ldb-panel-item:hover { background: #334155; color: #e2e8f0; }
.dark .ldb-panel-item.active { background: var(--ldb-primary-darkest); color: #a5b4fc; }
.dark .ldb-panel-item .ldb-panel-badge { background: var(--ldb-primary-darkest); color: #a5b4fc; }
.dark .ldb-panel-footer { border-top-color: #334155; }
.dark .ldb-user-menu { background: #1e293b; border-color: #334155; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
.dark #ldb-main { background: #0f172a; }
.dark .ldb-mobile-header { background: #1e293b; border-bottom-color: #334155; }

/* ── Brand color overrides: Tailwind indigo → LamDB Petrol ─────────────────
   Alle Tailwind-indigo-Klassen werden auf die LamDB-Petrolpalette umgebogen,
   damit keine PHP-Dateien für reine Farbwechsel angefasst werden müssen.
   ────────────────────────────────────────────────────────────────────────── */
.bg-indigo-50,  .hover\:bg-indigo-50:hover   { background-color: var(--ldb-primary-bg) !important; }
.bg-indigo-100, .hover\:bg-indigo-100:hover  { background-color: #cceaee !important; }
.bg-indigo-200                                { background-color: #99d5dd !important; }
.bg-indigo-600, .hover\:bg-indigo-600:hover  { background-color: var(--ldb-primary) !important; }
.bg-indigo-700, .hover\:bg-indigo-700:hover  { background-color: var(--ldb-primary-text) !important; }
.bg-indigo-800, .hover\:bg-indigo-800:hover  { background-color: #004455 !important; }

.text-indigo-400                              { color: #4da8b8 !important; }
.text-indigo-500                              { color: var(--ldb-primary) !important; }
.text-indigo-600                              { color: var(--ldb-primary) !important; }
.text-indigo-700                              { color: var(--ldb-primary-text) !important; }
.text-indigo-800                              { color: #004455 !important; }
.text-indigo-900                              { color: #003344 !important; }
.hover\:text-indigo-600:hover                 { color: var(--ldb-primary) !important; }
.hover\:text-indigo-700:hover                 { color: var(--ldb-primary-text) !important; }
.hover\:text-indigo-800:hover                 { color: #004455 !important; }
.group:hover .group-hover\:text-indigo-400    { color: #4da8b8 !important; }
.group:hover .group-hover\:text-indigo-500    { color: var(--ldb-primary) !important; }
.group:hover .group-hover\:text-indigo-700    { color: var(--ldb-primary-text) !important; }

.border-indigo-100                            { border-color: #cceaee !important; }
.border-indigo-200                            { border-color: #99d5dd !important; }
.border-indigo-300                            { border-color: #66c0cc !important; }
.border-indigo-400                            { border-color: #4da8b8 !important; }
.border-indigo-500                            { border-color: var(--ldb-primary) !important; }
.border-indigo-600                            { border-color: var(--ldb-primary) !important; }
.hover\:border-indigo-300:hover               { border-color: #66c0cc !important; }
.hover\:border-indigo-400:hover               { border-color: #4da8b8 !important; }

.has-\[\:checked\]\:border-indigo-500:has(:checked) { border-color: var(--ldb-primary) !important; }
.has-\[\:checked\]\:bg-indigo-50:has(:checked)      { background-color: var(--ldb-primary-bg) !important; }

.focus\:ring-indigo-500:focus                 { --tw-ring-color: var(--ldb-primary) !important; }
.shadow-indigo-200                            { --tw-shadow-color: rgba(0,104,122,0.25) !important; }

/* Gradient-Hintergrund für Login/Install (to-indigo-50 → Petrol-Hauch) */
.to-indigo-50 { --tw-gradient-to: var(--ldb-primary-bg) !important; }

/* ---- ldb-toggle-sm ON state ----------------------------------------------- */
.ldb-toggle-sm--on,
.ldb-toggle-sm[aria-checked="true"] {
  background: var(--ldb-primary);
}
.ldb-toggle-sm--on::after,
.ldb-toggle-sm[aria-checked="true"]::after {
  transform: translateX(11px);
}

/* ---- Form-Options Floating Button (rechts unten in der Formularansicht) ---- */
.form-opts-float-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  transition: all 0.15s;
}
.form-opts-float-btn:hover,
.form-opts-float-btn.active {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}
.form-opts-float-btn.active {
  background: var(--ldb-primary-bg);
  border-color: var(--ldb-primary);
  color: var(--ldb-primary);
}
.dark .form-opts-float-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}
.dark .form-opts-float-btn:hover,
.dark .form-opts-float-btn.active {
  background: #334155;
  color: #e2e8f0;
}

/* ---- Form-Options Panel Close Button --------------------------------------- */
.form-opts-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: none;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.form-opts-close-btn:hover {
  background: #f1f5f9;
  color: #475569;
}
.dark .form-opts-close-btn { color: #64748b; }
.dark .form-opts-close-btn:hover { background: #334155; color: #94a3b8; }

/* ---- fo-fields-list Scrollbalken-Abstand ----------------------------------- */
#fo-fields-list {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  padding-right: 8px;
}
#fo-fields-list::-webkit-scrollbar { width: 4px; }
#fo-fields-list::-webkit-scrollbar-track { background: transparent; }
#fo-fields-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* ---- Share Modal als Slide-Panel von rechts -------------------------------- */
/* Always display:flex so CSS transition fires; visibility+pointer-events control hide */
#modal-share.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
  background: rgba(0,0,0,0) !important;
  backdrop-filter: none !important;
  transition: background 0.25s ease, visibility 0s linear 0.25s !important;
}
#modal-share {
  /* Override: kein zentriertes Modal, sondern rechts-Slide */
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
  background: rgba(0,0,0,0);
  backdrop-filter: none;
  transition: background 0.25s ease;
  visibility: visible;
  pointer-events: auto;
}
#modal-share:not(.hidden) {
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
}
#modal-share .modal-box {
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  border-left: 1px solid #e2e8f0;
  margin: 0;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
#modal-share:not(.hidden) .modal-box {
  transform: translateX(0);
}
#modal-share .modal-header {
  flex-shrink: 0;
}
#modal-share #share-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#modal-share .modal-footer {
  flex-shrink: 0;
}
.dark #modal-share .modal-box {
  border-left-color: #334155;
}

/* ---- Form-Options Toggle Button (Sidebar-Icon) — entfernt aus Toolbar ------- */
.form-opts-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.form-opts-toggle-btn:hover,
.form-opts-toggle-btn.active {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}
.form-opts-toggle-btn.active {
  background: var(--ldb-primary-bg);
  border-color: var(--ldb-primary);
  color: var(--ldb-primary);
}
.dark .form-opts-toggle-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}
.dark .form-opts-toggle-btn:hover,
.dark .form-opts-toggle-btn.active {
  background: #334155;
  color: #e2e8f0;
}

/* ---- Form View Banner ------------------------------------------------------ */
.form-view-banner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  flex-shrink: 0;
}
.form-view-banner-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}
.form-view-banner-logo-img {
  object-fit: contain;
  /* size controlled inline via style attribute */
}
.form-view-banner-logo-default {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--ldb-primary);
}
/* Form view heading (title + desc below banner) */
.form-view-heading {
  max-width: 680px;
  margin: 16px auto 0;
  padding: 0 16px;
}

/* ---- Share Modal ----------------------------------------------------------- */
.share-section {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
}
.share-section + .share-section {
  margin-top: 0;
}
.share-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 12px;
}
.share-type-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 500;
  background: #f1f5f9;
  color: #64748b;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
}
#share-modal-body .space-y-3 > * + * { margin-top: 12px; }
.dark .share-section { background: #1e293b; border-color: #334155; }
.dark .share-section-title { color: #e2e8f0; }
.dark .share-type-badge { background: #334155; color: #94a3b8; border-color: #475569; }
