/* ═══════════════════════════════════════════════════════
   GX.customFields v2 — Styles
   ═══════════════════════════════════════════════════════ */

/* ── Backdrops ── */
.gx-cf-backdrop {
  z-index: 1060;
}
.gx-cf-field-backdrop {
  z-index: 1070;
}

/* Confirm dialog must appear above custom fields modals */
.gx-confirm-backdrop {
  z-index: 1090 !important;
}

/* Toast must appear above all custom fields modals */
.gx-toast-container {
  z-index: 1100 !important;
}


/* ══════════════════════════════════════════════════════
   1. GEAR ICON (inside .gx-crud-tabs)
   ══════════════════════════════════════════════════════ */

.gx-cf-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: auto;
  margin-right: 8px;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--gx-text-muted, #94a3b8);
  cursor: pointer;
  transition: all 0.15s;
}

.gx-cf-gear:hover {
  background: var(--gx-bg-hover, rgba(0,0,0,0.06));
  color: var(--gx-text, #334155);
}

.gx-cf-gear:active {
  transform: scale(0.93);
}


/* ══════════════════════════════════════════════════════
   2. DROPDOWN MENU
   ══════════════════════════════════════════════════════ */

.gx-cf-dropdown {
  z-index: 1080;
  background: var(--gx-bg, #fff);
  border: 1px solid var(--gx-border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  padding: 4px;
  min-width: 200px;
  animation: gxCfDropIn 0.12s ease-out;
}

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

.gx-cf-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--gx-text, #334155);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.gx-cf-dropdown__item:hover {
  background: var(--gx-bg-hover, #f1f5f9);
}

.gx-cf-dropdown__item i,
.gx-cf-dropdown__item svg {
  color: var(--gx-text-muted, #64748b);
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════
   3. EDITOR PANELS (Field Editor, Tab Editor, Reorder)
   ══════════════════════════════════════════════════════ */

.gx-cf-editor__body {
  padding: 16px 20px 28px !important;
  overflow-y: auto;
  max-height: 65vh;
  position: relative;
}

.gx-cf-editor__actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

/* ── Section dividers ── */
.gx-cf-editor__section {
  margin-bottom: 20px;
}

.gx-cf-editor__section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gx-text-muted, #94a3b8);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gx-border, #e2e8f0);
}

/* ── Empty state ── */
.gx-cf-editor__empty {
  text-align: center;
  padding: 30px 16px;
  color: var(--gx-text-muted, #94a3b8);
}

.gx-cf-editor__empty p {
  margin: 0 0 4px;
  font-size: 13px;
}

.gx-cf-editor__empty-hint {
  font-size: 12px !important;
  opacity: 0.7;
}


/* ══════════════════════════════════════════════════════
   4. FIELD ITEMS (shared between editor modes)
   ══════════════════════════════════════════════════════ */

.gx-cf-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gx-border, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 6px;
  transition: all 0.15s;
  background: var(--gx-bg, #fff);
}

.gx-cf-field--native {
  opacity: 0.75;
}

.gx-cf-field--custom:hover {
  border-color: var(--gx-primary, #3b82f6);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.gx-cf-field__icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--gx-bg-subtle, #f1f5f9);
  color: var(--gx-primary, #3b82f6);
  flex-shrink: 0;
}

.gx-cf-field--native .gx-cf-field__icon {
  color: var(--gx-text-muted, #94a3b8);
}

.gx-cf-field__info {
  flex: 1;
  min-width: 0;
}

.gx-cf-field__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gx-text, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gx-cf-field__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  font-size: 11px;
  color: var(--gx-text-muted, #94a3b8);
}

.gx-cf-field__actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.gx-cf-field__actions--visible {
  opacity: 1;
}

.gx-cf-field:hover .gx-cf-field__actions {
  opacity: 1;
}

.gx-btn--ghost-danger:hover {
  color: #dc2626 !important;
  background: #fef2f2 !important;
}


/* ══════════════════════════════════════════════════════
   5. BADGE
   ══════════════════════════════════════════════════════ */

.gx-cf-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.gx-cf-badge--system {
  background: var(--gx-bg-subtle, #f1f5f9);
  color: var(--gx-text-muted, #94a3b8);
}


/* ══════════════════════════════════════════════════════
   6. TAB EDITOR
   ══════════════════════════════════════════════════════ */

.gx-cf-tablist {
  margin-bottom: 16px;
}

.gx-cf-tabitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gx-border, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--gx-bg, #fff);
  transition: all 0.15s;
}

.gx-cf-tabitem--custom {
  cursor: grab;
}
.gx-cf-tabitem--custom:hover {
  border-color: var(--gx-primary, #7c3aed);
}
.gx-cf-tabitem--custom.is-dragging {
  opacity: 0.3;
}

.gx-cf-tabitem--pinned {
  background: var(--gx-bg-muted, #f9fafb);
  opacity: 0.8;
  cursor: default;
}

.gx-cf-tabitem__drag {
  color: var(--gx-text-muted, #9ca3af);
  cursor: grab;
  flex-shrink: 0;
}

.gx-cf-tabitem__drag--locked {
  cursor: default;
  opacity: 0.4;
}

.gx-cf-tabitem__icon {
  flex-shrink: 0;
  color: var(--gx-primary, #7c3aed);
  display: flex;
  align-items: center;
}

.gx-cf-tabitem__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.gx-cf-tabitem__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--gx-text, #1e293b);
}

.gx-cf-tabitem__desc {
  font-size: 12px;
  color: var(--gx-text-muted, #9ca3af);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gx-cf-tabitem__actions {
  display: flex;
  gap: 2px;
}

/* ── Tab inline edit ── */
.gx-cf-tabitem__edit-input {
  flex: 1;
  min-width: 0;
}
.gx-cf-tabitem__edit-icon {
  flex-shrink: 0;
}

.gx-cf-tabitem--editing {
  border-color: var(--gx-primary, #7c3aed);
  background: var(--gx-bg-muted, #f9fafb);
  cursor: default;
  flex-wrap: wrap;
  gap: 6px;
}

.gx-cf-tabitem__edit-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.gx-cf-tabitem__edit-desc {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

/* ── Tab drag placeholder ── */
.gx-cf-drop-placeholder--tab {
  border: 2px dashed var(--gx-primary, #7c3aed);
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.06);
  margin-bottom: 6px;
}

/* ── New tab input ── */
.gx-cf-newtab {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--gx-border, #e2e8f0);
  align-items: center;
}

.gx-cf-newtab--top {
  padding-top: 0;
  padding-bottom: 8px;
  margin-bottom: 0;
  border-top: none;
  border-bottom: none;
}

.gx-cf-newtab__desc-row {
  display: flex;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--gx-border, #e2e8f0);
  padding-left: 0;
}

.gx-cf-newtab__input {
  flex: 1;
}

.gx-cf-newtab__icon-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--gx-primary, #7c3aed);
}

.gx-cf-newtab--disabled {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--gx-border, #e2e8f0);
}

.gx-cf-newtab__limit-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--gx-bg-muted, #f9fafb);
  border: 1px solid var(--gx-border, #e2e8f0);
  color: var(--gx-text-muted, #9ca3af);
  font-size: 13px;
}

.gx-cf-newtab__counter {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--gx-text-muted, #9ca3af);
  background: var(--gx-bg-muted, #f1f3f5);
  padding: 2px 8px;
  border-radius: 10px;
}

/* ── Icon picker popover ── */
.gx-cf-iconpicker {
  position: absolute;
  z-index: 20;
  background: var(--gx-bg, #fff);
  border: 1px solid var(--gx-border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 10px;
  max-width: 320px;
  max-height: 240px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
}
.gx-cf-iconpicker.is-open {
  opacity: 1;
  transform: translateY(0);
}

.gx-cf-iconpicker__grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.gx-cf-iconpicker__item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--gx-text-secondary, #64748b);
  transition: all 0.1s;
}
.gx-cf-iconpicker__item:hover {
  background: var(--gx-bg-muted, #f1f5f9);
  color: var(--gx-primary, #7c3aed);
}
.gx-cf-iconpicker__item.is-selected {
  background: rgba(124, 58, 237, 0.1);
  color: var(--gx-primary, #7c3aed);
  box-shadow: inset 0 0 0 2px var(--gx-primary, #7c3aed);
}


/* ══════════════════════════════════════════════════════
   7. REORDER PANEL
   ══════════════════════════════════════════════════════ */

.gx-cf-reorder__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gx-border, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--gx-bg, #fff);
  transition: all 0.15s;
}

.gx-cf-reorder__item:hover {
  border-color: var(--gx-primary-light, #93c5fd);
  background: var(--gx-bg-subtle, #f8fafc);
}

.gx-cf-reorder__label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--gx-text, #1e293b);
}

.gx-cf-reorder__btns {
  display: flex;
  gap: 2px;
}

.gx-cf-reorder__btns button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}


/* ══════════════════════════════════════════════════════
   8. FIELD FORM MODAL
   ══════════════════════════════════════════════════════ */

.gx-cf-field-modal .gx-crud-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.gx-cf-field-modal .gx-field--full {
  grid-column: 1 / -1;
}

.gx-field__hint {
  font-size: 11px;
  color: var(--gx-text-muted, #94a3b8);
  margin-top: 4px;
}


/* ══════════════════════════════════════════════════════
   10. FIELD EDITOR — Layout Modes (form sim + table sim)
   ══════════════════════════════════════════════════════ */

/* ── Layout modal overrides ── */
.gx-cf-editor--layout {
  max-width: 1000px;
  position: relative;
}

.gx-cf-editor--layout .gx-cf-editor__body {
  max-height: 75vh;
}

/* ── Toolbar ── */
.gx-cf-layout__toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.gx-cf-layout__hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--gx-text-muted, #94a3b8);
}


/* ─── ROW-BASED GRID MODE (form / accordion) ─── */

.gx-cf-rowgrid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gx-cf-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  padding: 6px 8px;
  border: 1.5px dashed transparent;
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
  min-height: 56px;
}

.gx-cf-row:hover {
  border-color: var(--gx-border, #e2e8f0);
  background: rgba(248, 250, 252, 0.5);
}

/* ── "New row" drop zone at bottom ── */
.gx-cf-newrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  border: 2px dashed var(--gx-border, #e2e8f0);
  border-radius: 10px;
  color: var(--gx-text-muted, #94a3b8);
  font-size: 13px;
  transition: all 0.2s;
  margin-top: 4px;
}

.gx-cf-newrow.is-hover {
  border-color: var(--gx-primary, #7c3aed);
  background: rgba(124, 58, 237, 0.06);
  color: var(--gx-primary, #7c3aed);
}

/* ── Field card ── */

.gx-cf-fcard {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--gx-border, #e2e8f0);
  border-radius: 8px;
  background: var(--gx-bg, #fff);
  min-height: 52px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.2s;
  cursor: grab;
}

.gx-cf-fcard:hover {
  border-color: var(--gx-primary, #7c3aed);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.10);
}

.gx-cf-fcard:active { cursor: grabbing; }

.gx-cf-fcard.is-dragging {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  overflow: hidden;
}

.gx-cf-fcard--custom {
  border-color: var(--gx-primary-light, #c4b5fd);
  background: #faf8ff;
}

.gx-cf-fcard__drag {
  color: var(--gx-text-muted, #b0b8c8);
  flex-shrink: 0;
  cursor: grab;
}

.gx-cf-fcard__icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--gx-bg-subtle, #f1f5f9);
  color: var(--gx-primary, #7c3aed);
  flex-shrink: 0;
}

.gx-cf-fcard__body {
  flex: 1;
  min-width: 0;
}

.gx-cf-fcard__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gx-text, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gx-cf-fcard__type {
  font-size: 11px;
  color: var(--gx-text-muted, #94a3b8);
  margin-top: 1px;
}

.gx-cf-fcard__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* ── Drop placeholder (inside a row) ── */
.gx-cf-drop-placeholder {
  pointer-events: none;
  padding: 0;
  min-height: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.gx-cf-drop-placeholder__inner {
  width: 100%;
  height: 48px;
  border: 2px dashed var(--gx-primary, #7c3aed);
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.06);
}


/* ─── TABLE STRIP MODE ─── */

.gx-cf-tablestrip {
  border: 1px solid var(--gx-border, #e2e8f0);
  border-radius: 8px;
  background: var(--gx-bg-subtle, #f8fafc);
  padding: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.gx-cf-tablestrip__row {
  display: flex;
  gap: 6px;
  min-width: min-content;
}

.gx-cf-tcol {
  flex: 0 0 auto;
  width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 10px 10px;
  border: 1.5px solid var(--gx-border, #e2e8f0);
  border-radius: 8px;
  background: var(--gx-bg, #fff);
  text-align: center;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.2s;
  cursor: grab;
}

.gx-cf-tcol:hover {
  border-color: var(--gx-primary, #7c3aed);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.10);
}

.gx-cf-tcol:active { cursor: grabbing; }

.gx-cf-tcol.is-dragging { opacity: 0.25; }

.gx-cf-tcol--custom {
  border-color: var(--gx-primary-light, #c4b5fd);
  background: #faf8ff;
}

.gx-cf-tcol__drag {
  position: absolute;
  top: 3px;
  right: 4px;
  color: var(--gx-text-muted, #c4b5fd);
  cursor: grab;
}

.gx-cf-tcol__icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--gx-bg-subtle, #f1f5f9);
  color: var(--gx-primary, #7c3aed);
}

.gx-cf-tcol__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gx-text, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.gx-cf-tcol__type {
  font-size: 10px;
  color: var(--gx-text-muted, #94a3b8);
}

.gx-cf-tcol__actions {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}


/* ─── Drag-and-drop placeholder (table mode) ─── */

.gx-cf-drop-placeholder--tcol {
  border: 2px dashed var(--gx-primary, #7c3aed);
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.06);
  width: 50px;
  min-width: 50px;
  flex-shrink: 0;
  align-self: stretch;
}


/* ─── Loading overlay (field editor refresh) ─── */

.gx-cf-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
  animation: gx-cf-overlay-in 0.15s ease-out;
}

@keyframes gx-cf-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gx-cf-loading-overlay__spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--gx-primary, #7c3aed);
  font-size: 13px;
  font-weight: 500;
}

.gx-cf-loading-overlay__spinner svg {
  animation: gx-cf-spin 0.7s linear infinite;
}

@keyframes gx-cf-spin {
  to { transform: rotate(360deg); }
}

.gx-cf-loading-overlay.is-error {
  background: rgba(255, 255, 255, 0.95);
}
.gx-cf-loading-overlay.is-error .gx-cf-loading-overlay__spinner {
  color: var(--gx-danger, #e74c3c);
}
.gx-cf-loading-overlay.is-error .gx-cf-loading-overlay__spinner svg {
  animation: none;
}


/* ══════════════════════════════════════════════════════
   9. RESPONSIVE
   ══════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .gx-cf-field-modal .gx-crud-form__grid {
    grid-template-columns: 1fr;
  }

  /* Force all cards to full width on mobile */
  .gx-cf-row .gx-cf-fcard {
    grid-column: 1 / -1 !important;
  }

  .gx-cf-layout__toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .gx-cf-tcol {
    width: 120px;
  }

  .gx-cf-dropdown {
    min-width: 180px;
  }

  .gx-cf-newtab {
    flex-wrap: wrap;
  }
  .gx-cf-newtab__input {
    flex: 1 1 60%;
  }
}