/* =====================================================================
   LandEMI — CRUD utilities: confirm modal, table search, empty states
   ===================================================================== */

/* ── Confirm modal ──────────────────────────────────────────────── */
.land-confirm {
  position: fixed; inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.land-confirm.is-open { display: flex; animation: lc-fade .15s ease-out; }
.land-confirm__backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.land-confirm__dialog {
  position: relative;
  background: var(--bg-elev, #fff);
  border-radius: var(--radius, 10px);
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  padding: 1.75rem 1.5rem 1.25rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: lc-pop .18s cubic-bezier(.34, 1.56, .64, 1);
}
.land-confirm__icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(220, 38, 38, .1);
  color: #dc2626;
  font-size: 1.8rem;
  font-weight: 800;
  display: grid; place-items: center;
  margin: 0 auto .75rem;
}
.land-confirm__title {
  margin: 0 0 .5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text, #0f172a);
}
.land-confirm__message {
  color: var(--text-muted, #64748b);
  font-size: .95rem;
  line-height: 1.55;
  margin: 0 0 1.25rem;
}
.land-confirm__actions {
  display: flex;
  gap: .5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.land-confirm__actions .btn { min-width: 110px; }

@keyframes lc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lc-pop  {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Table search bar ───────────────────────────────────────────── */
.table-search {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--bg, #fafbfc);
}
.table-search__input {
  flex: 1;
  max-width: 360px;
  padding: .45rem .75rem !important;
  font-size: .875rem !important;
}
.table-search__count {
  font-size: .8rem;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
}
.table-search__empty td {
  background: var(--bg, #f8fafc);
  font-style: italic;
}

/* ── Empty state helper ─────────────────────────────────────────── */
.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted, #64748b);
}
.empty-state__icon {
  font-size: 3rem;
  opacity: .4;
  margin-bottom: .75rem;
}
.empty-state__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text, #0f172a);
  margin-bottom: .35rem;
}
.empty-state__description {
  font-size: .9rem;
  max-width: 400px;
  margin: 0 auto 1rem;
  line-height: 1.55;
}

/* ── Action bar (sticky form footer) ───────────────────────────── */
.action-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-elev, #fff);
  border-top: 1px solid var(--border, #e2e8f0);
  padding: .75rem 1rem;
  padding-bottom: max(.75rem, env(safe-area-inset-bottom, .75rem));
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 1rem;
  box-shadow: 0 -4px 12px rgba(0,0,0,.04);
  z-index: 10;
}
@media (max-width: 480px) {
  .action-bar { justify-content: stretch; }
  .action-bar .btn { flex: 1; min-width: 0; }
}

/* ── Command palette ────────────────────────────────────────────── */
.land-cpal {
  position: fixed; inset: 0;
  z-index: 10001;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 1rem 1rem;
}
.land-cpal.is-open { display: flex; animation: lc-fade .12s ease-out; }
.land-cpal__backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(3px);
}
.land-cpal__dialog {
  position: relative;
  background: var(--bg-elev, #fff);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
  max-width: 640px;
  width: 100%;
  overflow: hidden;
  animation: cpal-pop .18s ease-out;
}
@keyframes cpal-pop {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.land-cpal__search {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.land-cpal__icon { font-size: 1.15rem; opacity: .6; }
.land-cpal__input {
  flex: 1;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  font-size: 1.05rem !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--text, #0f172a);
}
.land-cpal__input::placeholder { color: var(--text-muted, #94a3b8); }
.land-cpal__esc, .land-cpal kbd, .land-kbd-help kbd {
  display: inline-block;
  padding: .15rem .45rem;
  font-size: .72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg, #f1f5f9);
  color: var(--text-muted, #64748b);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 4px;
  line-height: 1.2;
}
.land-cpal__list {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: .4rem 0;
}
.land-cpal__group-label {
  padding: .65rem 1.25rem .3rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted, #94a3b8);
}
.land-cpal__item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.25rem;
  cursor: pointer;
  transition: background .08s;
}
.land-cpal__item.is-selected,
.land-cpal__item:hover {
  background: rgba(37,99,235,.08);
}
.land-cpal__item.is-selected {
  background: rgba(37,99,235,.12);
  border-left: 3px solid var(--brand, #2563eb);
  padding-left: calc(1.25rem - 3px);
}
.land-cpal__type-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}
.land-cpal__item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.land-cpal__item-label {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.land-cpal__item-hint {
  font-size: .75rem;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.land-cpal__enter-hint {
  opacity: 0;
  transition: opacity .1s;
}
.land-cpal__item.is-selected .land-cpal__enter-hint { opacity: 1; }
.land-cpal__empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted, #94a3b8);
  font-size: .9rem;
}
.land-cpal__hint {
  padding: .6rem 1.25rem;
  border-top: 1px solid var(--border, #e2e8f0);
  background: var(--bg, #fafbfc);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .72rem;
  color: var(--text-muted, #64748b);
  align-items: center;
}
.land-cpal__hint kbd { font-size: .68rem; }

/* ── Palette trigger button in topbar ───────────────────────────── */
.cpal-trigger {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .75rem;
  background: var(--bg, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  font-size: .82rem;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  min-width: min(180px, 100%);
  max-width: 260px;
  transition: border-color .15s, background .15s;
}
.cpal-trigger:hover {
  border-color: var(--brand, #2563eb);
  background: var(--bg-elev, #fff);
}
.cpal-trigger__label { flex: 1; text-align: left; }
.cpal-trigger__kbd {
  display: inline-flex;
  gap: 2px;
  font-size: .68rem;
}
.cpal-trigger__kbd kbd {
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-elev, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 3px;
}

/* ── Breadcrumbs ────────────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--text-muted, #64748b);
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--text-muted, #64748b);
  text-decoration: none;
  transition: color .15s;
}
.breadcrumbs a:hover { color: var(--brand, #2563eb); }
.breadcrumbs__sep { opacity: .4; font-size: .75rem; }
.breadcrumbs__current {
  color: var(--text, #0f172a);
  font-weight: 500;
}

/* ── Keyboard shortcut help modal ───────────────────────────────── */
.land-kbd-help {
  position: fixed; inset: 0;
  z-index: 10002;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.land-kbd-help.is-open { display: flex; animation: lc-fade .15s; }
.land-kbd-help__backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(2px);
}
.land-kbd-help__dialog {
  position: relative;
  background: var(--bg-elev, #fff);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  animation: cpal-pop .2s;
}
.land-kbd-help__title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}
.land-kbd-help__rows {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.land-kbd-help__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border, #f1f5f9);
  font-size: .875rem;
}
.land-kbd-help__row:last-child { border-bottom: none; }
.land-kbd-help__label { color: var(--text, #0f172a); }
.land-kbd-help__keys { display: inline-flex; gap: 4px; }
.land-kbd-help__footer {
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Sortable columns ──────────────────────────────────────────── */
.sortable-th {
  position: relative;
  transition: background .12s;
}
.sortable-th:hover {
  background: rgba(37,99,235,.06) !important;
}
.sortable-th .sort-arrow {
  display: inline-block;
  transition: transform .1s;
}

/* ── Export button in table search ──────────────────────────────── */
.table-search__export {
  margin-left: auto !important;
}

/* ── Mobile responsive overrides ──────────────────────────────── */
@media (max-width: 640px) {
  .table-search { flex-wrap: wrap; gap: .5rem; }
  .table-search__input { max-width: 100%; }
  .table-search__count { width: 100%; order: 3; }
  .land-confirm__dialog {
    /* Bottom sheet: slides up from viewport bottom on mobile */
    padding: 1.35rem 1.1rem calc(1rem + var(--bn-h, 64px) + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    max-width: 100% !important;
    animation: lc-sheet .22s cubic-bezier(.32,.72,0,1);
  }
  .land-confirm {
    align-items: flex-end;
    padding: 0;
  }
  .land-cpal {
    padding: max(var(--safe-top,0px), 2vh) .75rem 0;
    align-items: flex-start;
  }
  .land-cpal__dialog { border-radius: 16px; }
  .land-cpal__list { max-height: 55vh; }
  .empty-state { padding: 1.75rem 1rem; }
  .empty-state__icon { font-size: 2.2rem; }
}

/* Action bar: on mobile it sticks above the fixed bottom nav */
@media (max-width: 767px) {
  .action-bar {
    bottom: calc(var(--bn-h, 64px) + env(safe-area-inset-bottom, 0px));
    z-index: 50;
  }
}
@keyframes lc-sheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Dark theme adjustments */
[data-theme="dark"] .land-confirm__dialog {
  background: #1e293b;
  color: #f1f5f9;
}
[data-theme="dark"] .land-confirm__title { color: #f1f5f9; }
[data-theme="dark"] .land-confirm__message { color: #94a3b8; }
[data-theme="dark"] .land-confirm__icon {
  background: rgba(220, 38, 38, .15);
}
[data-theme="dark"] .table-search {
  background: rgba(255,255,255,.02);
  border-color: rgba(255,255,255,.08);
}
[data-theme="dark"] .land-cpal__dialog,
[data-theme="dark"] .land-kbd-help__dialog {
  background: #1e293b;
  color: #f1f5f9;
}
[data-theme="dark"] .land-cpal__input { color: #f1f5f9; }
[data-theme="dark"] .land-cpal__item-label,
[data-theme="dark"] .land-kbd-help__label { color: #f1f5f9; }
[data-theme="dark"] .land-cpal__hint,
[data-theme="dark"] .cpal-trigger {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.08);
}
[data-theme="dark"] .cpal-trigger__kbd kbd,
[data-theme="dark"] .land-cpal kbd,
[data-theme="dark"] .land-kbd-help kbd {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.08);
  color: #cbd5e1;
}
