/* =============================================
   ADMIN PANEL STYLES
   Field Editor | Navigation | Drag & Drop | Settings
   ============================================= */

/* =============================================
   ADMIN NAVIGATION
   ============================================= */
.admin-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--app-shadow);
}

.admin-nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.admin-nav-btn:hover {
  background: var(--app-teal-light);
  color: var(--app-teal-dark);
}

.admin-nav-btn.active {
  background: var(--app-teal);
  color: white;
}

.admin-nav-btn i { font-size: 13px; }

/* =============================================
   ADMIN SUBVIEWS
   ============================================= */
.admin-subview { display: none; }
.admin-subview.active { display: block; animation: fade-in 0.25s ease; }

/* =============================================
   FIELD EDITOR - ADD FIELD FORM
   ============================================= */

#af_optionsRow {
  transition: opacity 0.2s ease, max-height 0.2s ease;
  overflow: hidden;
}

#af_optionsRow.hidden {
  display: none !important;
}

/* =============================================
   FIELD EDITOR - FIELD LIST
   ============================================= */

.field-def-list-header {
  display: grid;
  grid-template-columns: 30px 1fr 80px 100px;
  gap: 8px;
  padding: 8px 14px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--app-muted);
  border-bottom: 1px solid var(--app-line);
  margin-bottom: 8px;
}

/* Field definition item - enhanced */
.field-def-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--app-surface);
  border: 1.5px solid var(--app-line);
  border-radius: 10px;
  margin-bottom: 8px;
  transition: all var(--transition-fast);
  cursor: grab;
  position: relative;
}

.field-def-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--app-teal);
  border-radius: 10px 0 0 10px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.field-def-item:hover::before {
  opacity: 1;
}

.field-def-item:hover {
  border-color: var(--app-teal);
  box-shadow: 0 2px 8px rgba(14,107,102,0.1);
}

.field-def-item.dragging {
  opacity: 0.7;
  transform: scale(1.02) rotate(1deg);
  box-shadow: 0 8px 24px rgba(14,107,102,0.2);
  cursor: grabbing;
  z-index: 10;
}

.field-def-item.drag-over {
  border-color: var(--app-teal);
  border-style: dashed;
  background: var(--app-teal-light);
}

.field-def-item.system-field {
  opacity: 0.85;
  cursor: default;
}

.field-def-item.system-field .field-def-drag-handle {
  cursor: default;
  opacity: 0.4;
}

.field-def-item.system-field::before {
  background: var(--app-slate);
}

/* Drag Handle */
.field-def-drag-handle {
  color: var(--app-muted-2);
  padding: 4px;
  flex-shrink: 0;
}

/* Field Info */
.field-def-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field-def-info .fd-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--app-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-def-info .fd-meta {
  font-size: 11px;
  color: var(--app-muted);
  font-family: var(--font-mono);
}

/* Type Badge */
.field-def-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* Actions */
.field-def-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.field-def-actions button {
  background: none;
  border: none;
  color: var(--app-muted-2);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 13px;
}

.field-def-actions button:hover {
  background: var(--app-teal-light);
  color: var(--app-teal);
}

.field-def-actions button.delete:hover {
  background: var(--app-rose-light);
  color: var(--app-rose);
}

/* Required Badge */
.fd-required-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--app-rose-light);
  color: var(--app-rose);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
}

/* Visibility Toggle */
.fd-visibility-toggle {
  background: none;
  border: none;
  color: var(--app-muted-2);
  padding: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.fd-visibility-toggle:hover { color: var(--app-teal); }
.fd-visibility-toggle.hidden-field { color: var(--app-rose); }

/* =============================================
   SECTION BADGES
   ============================================= */
.section-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-badge.section-work { background: var(--app-teal-light); color: var(--app-teal-dark); }
.section-badge.section-location { background: var(--app-sky-light); color: var(--app-sky); }
.section-badge.section-pipe { background: var(--app-slate-light); color: var(--app-slate); }
.section-badge.section-fittings { background: var(--app-moss-light); color: var(--app-moss); }
.section-badge.section-manpower { background: var(--app-amber-light); color: var(--app-amber); }
.section-badge.section-contractor { background: var(--app-teal-light); color: var(--app-teal-dark); }
.section-badge.section-remarks { background: #F1F3F2; color: var(--app-muted); }
.section-badge.section-custom { background: #F0E6F3; color: #7B5A8A; }

/* =============================================
   LAYING WORK FILTER BADGE
   ============================================= */
.laying-filter-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(14,107,102,0.1);
  color: var(--app-teal);
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
}

/* =============================================
   ADMIN RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
  .admin-nav {
    flex-direction: column;
  }

  .admin-nav-btn {
    justify-content: flex-start;
  }

  .field-def-list-header {
    display: none;
  }

  .field-def-item {
    flex-wrap: wrap;
    gap: 8px;
  }

  .field-def-info {
    width: calc(100% - 50px);
  }

  .field-def-type-badge {
    margin-left: 30px;
  }

  .field-def-actions {
    margin-left: auto;
  }
}

@media (max-width: 480px) {
  .field-def-item {
    padding: 10px;
  }

  .field-def-info .fd-label {
    font-size: 12px;
  }

  .field-def-type-badge {
    font-size: 9.5px;
    padding: 2px 6px;
  }
}

/* ============================================================
   ADMIN FIELD EDITOR — full control (appended)
   System fields are now editable, hideable and reorderable.
   ============================================================ */
.field-def-item.system-field { cursor: grab; opacity: 1; }
.field-def-item.system-field:active { cursor: grabbing; }
.field-def-item.system-field .field-def-drag-handle { cursor: grab; opacity: 1; }
.field-def-actions button.edit:hover { background: var(--app-sky-light); color: var(--app-sky); }

/* ============================================================
   RESTORATION SECTION + WORK TYPE FILTER BADGE (appended)
   ============================================================ */
.section-badge.section-restoration { background: var(--app-amber-light); color: var(--app-amber); }

/* Work-type filter badge in the field list (distinct from laying-work badge) */
.laying-filter-badge.worktype-badge {
  background: rgba(46,125,166,0.12);
  color: var(--app-sky);
}

/* ============================================================
   DROPDOWN OPTIONS MANAGER (admin) — appended
   ============================================================ */
.dd-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dd-tab {
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--app-line); background: var(--app-surface, #fff);
  color: var(--app-ink); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.dd-tab:hover { border-color: var(--app-teal); }
.dd-tab.active { background: var(--app-teal); border-color: var(--app-teal); color: #fff; }

.dd-add { display: flex; gap: 10px; margin-bottom: 8px; }
.dd-add .sw-input { flex: 1 1 auto; min-width: 0; }
.dd-add .sw-btn { flex: 0 0 auto; }

.dd-count { font-size: 12px; color: var(--app-muted); margin-bottom: 12px; }

.dd-list { display: flex; flex-direction: column; gap: 8px; }
.dd-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--app-line); border-radius: 10px;
  background: var(--app-surface, #fff);
}
.dd-row.confirming { border-color: var(--app-rose); background: var(--app-rose-light); }
.dd-row.editing { border-color: var(--app-teal); }
.dd-row .dd-val { font-size: 14px; font-weight: 600; color: var(--app-ink); }
.dd-row .dd-suffix { font-size: 12px; font-weight: 500; color: var(--app-muted); margin-left: 4px; }
.dd-row .dd-edit-input { flex: 1 1 auto; min-width: 0; margin-right: 10px; }
.dd-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
