/* ============================================
   FORMS.CSS - Form Controls & Inputs
   Forms, checkboxes, inputs, selects, JSON editor
   ============================================ */

/* ============================================
   GLOBAL CARET COLOR FOR ALL INPUTS
   ============================================ */
input,
textarea,
[contenteditable="true"] {
  caret-color: var(--user-accent, var(--pro-accent-primary));
}

/* ============================================
   FORM CONTROLS BASE
   ============================================ */
input.form-control,
textarea.form-control,
select.form-control,
select.form-select,
.je-object__container input:not([type="checkbox"]),
.je-object__container textarea,
.je-object__container select {
  background: var(--pro-bg-secondary) !important;
  border: 1px solid var(--pro-border-color) !important;
  color: var(--pro-text-primary) !important;
  border-radius: 8px !important;
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md) !important;
  width: 100% !important;
  height: var(--btn-height-md);
  font-size: var(--btn-font-md);
  caret-color: var(--user-accent, var(--pro-accent-primary)) !important;
}

textarea.form-control,
.je-object__container textarea {
  min-height: 80px !important;
  height: auto;
  resize: vertical !important;
}

input.form-control:focus-visible,
textarea.form-control:focus-visible,
select.form-control:focus-visible,
.je-object__container input:focus-visible,
.je-object__container textarea:focus-visible,
.je-object__container select:focus-visible {
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
  border-color: var(--focus-ring-color) !important;
}

select.form-select {
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md);
  height: var(--btn-height-md);
  font-size: var(--btn-font-md);
  border-radius: 6px;
  border: 1px solid var(--pro-border-color);
  background: var(--pro-bg-secondary);
  color: var(--pro-text-primary);
}

select.form-select:focus-visible {
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
  border-color: var(--focus-ring-color);
}

/* Form groups spacing */
.form-group,
.je-indented-panel,
.je-child-editor-holder {
  margin-bottom: 20px !important;
}

/* Labels */
label,
.je-form-input-label {
  color: var(--pro-text-primary) !important;
  font-weight: 500;
  margin-bottom: 8px;
  display: block;
}

.form-text,
.je-form-input-hint {
  color: var(--pro-text-secondary) !important;
  opacity: 0.7;
  font-size: 12px !important;
}

/* Required field indicator */
label.required::after,
.je-form-input-label.required::after {
  content: " *";
  color: var(--user-accent, var(--pro-accent-primary));
}

/* ============================================
   INPUT GROUPS (Bootstrap override)
   ============================================ */
.input-group {
  display: flex;
  align-items: stretch;
  flex-direction: row;
  flex-wrap: nowrap;
}

.input-group-text {
  background: var(--pro-bg-tertiary);
  border: 1px solid var(--pro-border-color);
  border-right: none;
  color: var(--pro-text-secondary);
  padding: 0.375rem 0.75rem;
  border-radius: 8px 0 0 8px;
  display: flex;
  align-items: center;
  font-size: var(--btn-font-md, 0.875rem);
}

.input-group .form-control {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}

.input-group .form-control:focus {
  z-index: 1;
}

/* Input group with addon on right */
.input-group .input-group-text:last-child {
  border-left: none;
  border-right: 1px solid var(--pro-border-color);
  border-radius: 0 8px 8px 0;
}

.input-group .form-control:not(:last-child) {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

/* ============================================
   CHECKBOX STYLING
   ============================================ */
.je-checkbox-control {
  display: flex;
  align-items: center;
  padding: 10px 0;
  background: transparent !important;
}

.je-checkbox-control input[type="checkbox"],
#jsonEditorContainer input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  height: 20px !important;
  border: 2px solid var(--pro-border-color);
  border-radius: 4px;
  background: var(--pro-bg-secondary) !important;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  margin: 0 10px 0 0 !important;
  padding: 0 !important;
  flex-shrink: 0;
  flex-grow: 0;
}

.je-checkbox-control input[type="checkbox"]:checked,
#jsonEditorContainer input[type="checkbox"]:checked {
  background: var(--user-accent, var(--pro-accent-primary)) !important;
  border-color: var(--user-accent, var(--pro-accent-primary));
}

.je-checkbox-control input[type="checkbox"]:checked::after,
#jsonEditorContainer input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.je-checkbox-control input[type="checkbox"]:focus-visible,
#jsonEditorContainer input[type="checkbox"]:focus-visible {
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
}

.je-checkbox-control label {
  margin: 0 !important;
  padding: 0 !important;
}

/* Label styling for checkboxes */
.je-checkbox-control label,
.checkbox label,
label.form-check-label,
.form-check label {
  color: var(--pro-text-primary) !important;
  cursor: pointer;
  font-weight: 500 !important;
}

/* Override Bootstrap checkbox classes */
.form-check {
  background: transparent !important;
  padding: 10px 0 !important;
  padding-left: 0 !important;  /* Align with other form fields */
  margin-left: 0 !important;
}

.form-check-input {
  appearance: none !important;
  -webkit-appearance: none !important;
  margin-left: 0 !important;
  float: none !important;
}

.form-check-label {
  margin-left: 8px !important;
  display: inline !important;
}

/* Fix form-switch alignment in modals */
.form-check.form-switch {
  padding-left: 0 !important;
}

.form-check.form-switch .form-check-input {
  margin-left: 0 !important;
  float: none !important;
}

.form-check.form-switch .form-check-label {
  margin-left: 8px !important;
}

/* ============================================
   ERROR STYLING
   ============================================ */
.has-error input,
.has-error textarea,
.has-error select,
.je-child-editor-holder.has-error input,
.je-child-editor-holder.has-error textarea,
.je-child-editor-holder.has-error select {
  border-color: var(--pro-accent-danger) !important;
  background: var(--pro-accent-danger-muted) !important;
}

.error-message,
.je-error {
  color: var(--pro-accent-danger) !important;
  font-size: 12px !important;
  margin-top: 5px !important;
  display: block !important;
  font-weight: 500 !important;
}

.invalid-feedback {
  color: var(--pro-accent-danger) !important;
  font-size: 12px !important;
  display: block !important;
  margin-top: 5px !important;
}

/* ============================================
   JSON EDITOR CONTAINER
   ============================================ */
#jsonEditorContainer {
  background: var(--pro-bg-elevated);
  padding: 25px;
  border-radius: 12px;
  min-height: 350px;
}

/* Override Bootstrap bg-light class */
#jsonEditorContainer .bg-light,
.je-object__container.bg-light,
.je-indented-panel.bg-light {
  background: transparent !important;
}

.je-object__container,
.je-indented-panel {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Form field containers */
.je-child-editor-holder > div {
  margin-bottom: 20px;
}

.je-form-input-label {
  color: var(--pro-text-primary) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  margin-bottom: 8px !important;
  display: block !important;
}

.je-object__title {
  color: var(--user-accent, var(--pro-accent-primary)) !important;
  font-weight: 700 !important;
  margin-bottom: 20px;
  display: none; /* Hide root object title */
}

.je-switcher {
  background: var(--pro-bg-elevated) !important;
  border-color: var(--pro-border-color) !important;
  color: var(--pro-text-primary) !important;
}

.je-switcher:hover {
  background: var(--pro-bg-secondary) !important;
  border-color: var(--user-accent, var(--pro-accent-primary)) !important;
}

/* Button styling for JSON Editor controls */
.json-editor-btn-add,
.json-editor-btn-delete,
.json-editor-btn-move {
  background: var(--pro-bg-elevated) !important;
  border: 1px solid var(--pro-border-color) !important;
  color: var(--pro-text-primary) !important;
  border-radius: 8px !important;
  padding: 6px 12px !important;
  transition: all 0.2s ease !important;
}

.json-editor-btn-add:hover {
  background: var(--user-accent, var(--pro-accent-primary)) !important;
  border-color: var(--user-accent, var(--pro-accent-primary)) !important;
  color: white !important;
}

.json-editor-btn-delete:hover {
  background: var(--pro-accent-danger) !important;
  border-color: var(--pro-accent-danger) !important;
  color: white !important;
}

/* ============================================
   SEARCH BOX STYLES
   ============================================ */
.funky-search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.funky-search-box input {
  width: 100%;
  padding: var(--form-control-padding, 0.375rem 0.75rem);
  padding-left: calc(var(--pro-spacing-md, 1rem) + 1rem); /* room for icon */
  background: var(--pro-bg-secondary);
  border: 1px solid var(--pro-border-color);
  border-radius: 6px;
  color: var(--pro-text-primary);
  font-size: var(--btn-font-sm, 0.75rem);
  height: var(--form-control-height, 38px);
  transition: all 0.2s ease;
  caret-color: var(--user-accent, var(--pro-accent-primary));
}

.funky-search-box input:focus {
  outline: none;
  border-color: var(--focus-ring-color);
  box-shadow: 0 0 0 3px var(--user-accent-muted, rgba(47, 129, 247, 0.1));
}

.funky-search-box::before {
  content: '🔍';
  position: absolute;
  left: var(--pro-spacing-xs, 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--btn-font-md, 0.875rem);
  pointer-events: none;
}

.funky-search-box input:focus-visible {
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
}

/* ============================================
   SELECT2 INTEGRATION
   ============================================ */
.select2-container--default .select2-selection--single {
  background: var(--pro-bg-secondary) !important;
  border: 1px solid var(--pro-border-color) !important;
  border-radius: 8px !important;
  height: 38px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--pro-text-primary) !important;
  line-height: 36px !important;
}

.select2-dropdown {
  background: var(--pro-bg-elevated) !important;
  border: 1px solid var(--pro-border-color) !important;
  border-radius: 8px !important;
}

.select2-results__option {
  color: var(--pro-text-primary) !important;
}

.select2-results__option--highlighted {
  background: var(--user-accent, var(--pro-accent-primary)) !important;
}

/* Select2 Bootstrap 5 Theme Overrides */
.select2-container--bootstrap-5 .select2-selection {
  background: var(--pro-bg-secondary) !important;
  border: 1px solid var(--pro-border-color) !important;
  border-radius: 6px !important;
  padding: 6px 12px !important;
  height: 38px !important;
  min-height: 38px !important;
  transition: all 0.2s ease !important;
}

/* Modal form Select2 - match Bootstrap form controls */
.modal .select2-container--bootstrap-5 .select2-selection {
  border-radius: 0.375rem !important;
  padding: 0.375rem 0.75rem !important;
  height: 38px !important;
  min-height: 38px !important;
  border-width: 1px !important;
}

.modal .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  line-height: 1.5 !important;
  padding-left: 0 !important;
}

.modal .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
  height: 36px !important;
  right: 8px !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  color: var(--pro-text-primary) !important;
  padding-left: 0 !important;
  line-height: 26px !important;
  font-size: 12px !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
  color: var(--pro-text-secondary) !important;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: var(--focus-ring-color) !important;
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow) !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
  height: 36px !important;
  right: 10px !important;
}

.select2-container--bootstrap-5 .select2-dropdown {
  background: var(--pro-bg-elevated) !important;
  border: 1px solid var(--user-accent, var(--pro-accent-primary)) !important;
  border-radius: 8px !important;
  box-shadow: var(--pro-shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.3)) !important;
  z-index: 9999 !important;
}

.select2-container--bootstrap-5 .select2-results__option {
  padding: 8px 12px !important;
  color: var(--pro-text-primary) !important;
  font-size: 12px !important;
  transition: all 0.2s ease !important;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
  background: var(--pro-bg-secondary) !important;
  color: var(--user-accent, var(--pro-accent-primary)) !important;
}

.select2-container--bootstrap-5 .select2-results__option--selected {
  background: var(--user-accent, var(--pro-accent-primary)) !important;
  color: white !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
  background: var(--pro-bg-secondary) !important;
  border: 1px solid var(--pro-border-color) !important;
  border-radius: 6px !important;
  color: var(--pro-text-primary) !important;
  padding: 6px 10px !important;
  font-size: 12px !important;
  height: 32px !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus-visible {
  border-color: var(--focus-ring-color) !important;
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color) !important;
  outline-offset: var(--focus-ring-offset) !important;
}

.select2-container--bootstrap-5 .select2-selection__clear {
  color: var(--pro-text-secondary) !important;
  font-size: 16px !important;
  margin-right: 8px !important;
  transition: color 0.2s ease !important;
}

.select2-container--bootstrap-5 .select2-selection__clear:hover {
  color: var(--user-accent, var(--pro-accent-primary)) !important;
}

/* Multi-select Select2 */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
  background-color: var(--user-accent, var(--pro-accent-primary)) !important;
  border: none !important;
  border-radius: 4px !important;
  padding: 2px 8px !important;
  color: white !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  margin: 2px 3px 2px 0 !important;
  line-height: 1.3 !important;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
  color: white !important;
  opacity: 0.8 !important;
  font-weight: bold !important;
  margin-right: 4px !important;
  font-size: 0.7rem !important;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover {
  opacity: 1 !important;
}

/* Client Filter Container */
.funky-client-filter {
  display: inline-block;
  vertical-align: top;
}

.funky-client-filter select {
  width: 200px;
  height: 36px;
  font-size: 12px;
}

/* Date Filter Containers */
.funky-date-filter {
  display: inline-block;
  vertical-align: top;
}

.funky-date-filter select {
  width: 150px;
  background: var(--pro-bg-elevated);
  border: 1px solid var(--pro-border-color);
  color: var(--pro-text-primary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  height: 36px;
}

.funky-date-range {
  display: inline-block;
  vertical-align: top;
}

.funky-date-range input {
  width: 240px;
  background: var(--pro-bg-elevated);
  border: 1px solid var(--pro-border-color);
  color: var(--pro-text-primary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  height: 36px;
  cursor: pointer;
}

.funky-date-range input:hover {
  border-color: var(--user-accent, var(--pro-accent-primary));
}

.funky-date-range input:focus-visible {
  border-color: var(--focus-ring-color);
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ============================================
   TIMEZONE SELECTOR STYLES
   ============================================ */

/* Timezone Selector Base */
#globalTimezoneSelector {
  background: var(--pro-bg-elevated);
  border: 1px solid var(--pro-border-color);
  border-radius: 6px;
  color: var(--pro-text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  outline: none;
  min-width: 180px;
  transition: all 0.2s ease;
  height: 36px;
}

#globalTimezoneSelector:hover {
  border-color: var(--user-accent, var(--pro-accent-primary));
  box-shadow: 0 0 0 3px var(--user-accent-muted, rgba(255, 109, 0, 0.1));
}

#globalTimezoneSelector:focus-visible {
  border-color: var(--focus-ring-color);
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
}

/* Select2 Container for Timezone */
.select2-container--timezone {
  height: 36px;
}

/* Select2 Selection Box for Timezone */
.select2-container--timezone .select2-selection {
  background: var(--pro-bg-elevated) !important;
  border: 1px solid var(--pro-border-color) !important;
  border-radius: 6px !important;
  height: 36px !important;
  padding: 0 12px !important;
  display: flex !important;
  align-items: center !important;
  transition: all 0.2s ease !important;
}

.select2-container--timezone .select2-selection:hover {
  border-color: var(--user-accent, var(--pro-accent-primary)) !important;
  box-shadow: 0 0 0 3px var(--user-accent-muted, rgba(255, 109, 0, 0.1)) !important;
}

.select2-container--timezone.select2-container--focus .select2-selection,
.select2-container--timezone.select2-container--open .select2-selection {
  border-color: var(--user-accent, var(--pro-accent-primary)) !important;
  box-shadow: 0 0 0 3px var(--user-accent-muted, rgba(255, 109, 0, 0.15)) !important;
}

.select2-container--timezone .select2-selection__rendered {
  color: var(--pro-text-primary) !important;
  padding: 0 !important;
  line-height: 36px !important;
  font-weight: 500 !important;
  font-size: 12px !important;
}

.select2-container--timezone .select2-selection__arrow {
  height: 36px !important;
  right: 10px !important;
  width: 18px !important;
  top: 0 !important;
  display: flex !important;
  align-items: center !important;
}

.select2-container--timezone .select2-selection__arrow b {
  border-color: var(--pro-text-secondary) transparent transparent transparent !important;
  border-width: 5px 4px 0 4px !important;
  margin: 0 !important;
}

.select2-container--timezone.select2-container--open .select2-selection__arrow b {
  border-color: transparent transparent var(--user-accent, var(--pro-accent-primary)) transparent !important;
  border-width: 0 4px 5px 4px !important;
}

/* Select2 Dropdown for Timezone */
.select2-container--timezone .select2-dropdown {
  background: var(--pro-bg-elevated);
  border: 1px solid var(--user-accent, var(--pro-accent-primary));
  border-radius: 12px;
  box-shadow: var(--pro-shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.4));
  margin-top: 8px;
  overflow: hidden;
  min-width: 320px !important;
}

/* Search Field for Timezone */
.select2-container--timezone .select2-search--dropdown {
  padding: 12px;
  background: var(--pro-bg-elevated);
  border-bottom: 1px solid var(--pro-border-color);
}

.select2-container--timezone .select2-search--dropdown .select2-search__field {
  background: var(--pro-bg-secondary);
  border: 1px solid var(--pro-border-color);
  color: var(--pro-text-primary);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  width: 100%;
  transition: all 0.2s ease;
}

.select2-container--timezone .select2-search--dropdown .select2-search__field:focus-visible {
  border-color: var(--focus-ring-color);
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
}

.select2-container--timezone .select2-search--dropdown .select2-search__field::placeholder {
  color: var(--pro-text-secondary);
}

/* Results Container for Timezone */
.select2-container--timezone .select2-results {
  max-height: 400px;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.select2-container--timezone .select2-results__options {
  padding: 8px 0;
}

/* Group Headers for Timezone */
.select2-container--timezone .select2-results__group {
  color: var(--user-accent, var(--pro-accent-primary));
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px 6px;
  margin-top: 8px;
  background: var(--pro-bg-secondary);
  border-left: 3px solid var(--user-accent, var(--pro-accent-primary));
}

.select2-container--timezone .select2-results__group:first-child {
  margin-top: 0;
}

/* Group option containers need padding adjustment */
.select2-container--timezone .select2-results__option.select2-results__option--group {
  padding: 0 !important;
}

/* Options for Timezone */
.select2-container--timezone .select2-results__option {
  color: var(--pro-text-primary);
  padding: 11px 20px;
  font-size: 13px;
  transition: all 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
}

.select2-container--timezone .select2-results__option--highlighted {
  background: var(--user-accent, var(--pro-accent-primary)) !important;
  color: white !important;
}

.select2-container--timezone .select2-results__option[aria-selected="true"] {
  background: var(--user-accent-muted, rgba(255, 109, 0, 0.12)) !important;
  color: var(--user-accent, var(--pro-accent-primary)) !important;
  font-weight: 600 !important;
  position: relative;
}

.select2-container--timezone .select2-results__option[aria-selected="true"]::before {
  content: "✓";
  position: absolute;
  left: 6px;
  font-weight: bold;
  font-size: 14px;
}

.select2-container--timezone .select2-results__option[aria-selected="true"]:not(.select2-results__option--highlighted) {
  padding-left: 28px;
}

/* Scrollbar for timezone dropdown */
.select2-container--timezone .select2-results::-webkit-scrollbar {
  width: 10px;
}

.select2-container--timezone .select2-results::-webkit-scrollbar-track {
  background: var(--pro-bg-secondary);
  border-radius: 0 10px 10px 0;
}

.select2-container--timezone .select2-results::-webkit-scrollbar-thumb {
  background: var(--pro-border-color);
  border-radius: 10px;
  border: 2px solid var(--pro-bg-secondary);
}

.select2-container--timezone .select2-results::-webkit-scrollbar-thumb:hover {
  background: var(--user-accent, var(--pro-accent-primary));
}

/* ============================================
   FORM DENSITY STYLES
   Adjust form control sizes based on density
   ============================================ */

/* Compact Density */
[data-density="compact"] .form-control,
[data-density="compact"] .form-select {
  height: var(--btn-height-md);
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md);
  font-size: var(--btn-font-md);
}

[data-density="compact"] textarea.form-control {
  height: auto;
  min-height: 60px;
  padding: 6px 10px;
}

[data-density="compact"] .form-label {
  font-size: 12px;
  margin-bottom: 4px;
}

[data-density="compact"] .form-group {
  margin-bottom: 12px !important;
}

[data-density="compact"] .form-text {
  font-size: 11px;
}

[data-density="compact"] .input-group-text {
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md);
  font-size: var(--btn-font-md);
}

[data-density="compact"] .field-input-group-text {
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md);
  font-size: var(--btn-font-md);
}

/* Spacious Density */
[data-density="spacious"] .form-control,
[data-density="spacious"] .form-select {
  height: var(--btn-height-md);
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md);
  font-size: var(--btn-font-md);
}

[data-density="spacious"] textarea.form-control {
  height: auto;
  min-height: 100px;
  padding: 14px 18px;
}

[data-density="spacious"] .form-label {
  font-size: 14px;
  margin-bottom: 10px;
}

[data-density="spacious"] .form-group {
  margin-bottom: 24px !important;
}

[data-density="spacious"] .form-text {
  font-size: 13px;
}

[data-density="spacious"] .input-group-text {
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md);
  font-size: var(--btn-font-md);
}

[data-density="spacious"] .field-input-group-text {
  padding: var(--btn-padding-y-md) var(--btn-padding-x-md);
  font-size: var(--btn-font-md);
}

/* Select2 Density */
[data-density="compact"] .select2-container .select2-selection {
  height: 32px !important;
  min-height: 32px !important;
  font-size: 12px;
}

[data-density="compact"] .select2-container .select2-selection__rendered {
  line-height: 30px !important;
  padding-left: 10px !important;
  font-size: 12px;
}

[data-density="compact"] .select2-container .select2-selection__arrow {
  height: 30px !important;
}

[data-density="compact"] .select2-container .select2-selection--multiple {
  min-height: 32px !important;
  padding: 2px 6px;
}

[data-density="compact"] .select2-container .select2-selection--multiple .select2-selection__choice {
  font-size: 11px;
  padding: 2px 6px;
  margin: 2px;
}

[data-density="spacious"] .select2-container .select2-selection {
  height: 48px !important;
  min-height: 48px !important;
  font-size: 15px;
}

[data-density="spacious"] .select2-container .select2-selection__rendered {
  line-height: 46px !important;
  padding-left: 18px !important;
  font-size: 15px;
}

[data-density="spacious"] .select2-container .select2-selection__arrow {
  height: 46px !important;
}

[data-density="spacious"] .select2-container .select2-selection--multiple {
  min-height: 48px !important;
  padding: 6px 12px;
}

[data-density="spacious"] .select2-container .select2-selection--multiple .select2-selection__choice {
  font-size: 14px;
  padding: 4px 10px;
  margin: 4px;
}

/* Checkbox/Radio Density */
[data-density="compact"] .form-check {
  min-height: 18px;
  padding-left: 22px;
  margin-bottom: 6px;
}

[data-density="compact"] .form-check-input {
  width: 14px;
  height: 14px;
  margin-top: 2px;
}

[data-density="compact"] .form-check-label {
  font-size: 12px;
}

[data-density="spacious"] .form-check {
  min-height: 28px;
  padding-left: 32px;
  margin-bottom: 14px;
}

[data-density="spacious"] .form-check-input {
  width: 20px;
  height: 20px;
  margin-top: 3px;
}

[data-density="spacious"] .form-check-label {
  font-size: 15px;
}

/* Switch Density */
[data-density="compact"] .form-switch .form-check-input {
  width: 32px;
  height: 16px;
}

[data-density="spacious"] .form-switch .form-check-input {
  width: 48px;
  height: 24px;
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  .form-control,
  .form-select {
    border-width: 2px;
  }

  .form-control:focus-visible,
  .form-select:focus-visible {
    outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
    outline-offset: var(--focus-ring-offset);
    box-shadow: var(--focus-ring-shadow);
  }

  .form-check-input {
    border-width: 2px;
  }

  .form-check-input:checked {
    border-width: 2px;
  }

  .form-label {
    font-weight: 600;
  }

  .input-group-text {
    border-width: 2px;
  }

  .form-control:disabled,
  .form-select:disabled {
    border-style: dashed;
  }
}

/* ============================================
   FUNKY.FORM - Native Form Component
   ============================================ */

/* CSS Variables for Form Layout */
:root {
  --form-gap: 1rem;
  --form-section-radius: 8px;
  --form-section-padding: 1rem;
  --form-fieldset-border: 1px solid var(--pro-border-color);
}

/* Form Container */
.funky-form {
  width: 100%;
}

.funky-form-body {
  display: flex;
  flex-direction: column;
  gap: var(--form-gap);
}

/* Form Field Wrapper */
.funky-form-field {
  margin-bottom: 0; /* Gap handled by parent */
}

.funky-form-field label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--pro-text-primary);
}

.funky-form-field label.required::after {
  content: " *";
  color: var(--pro-accent-danger);
}

.funky-form-field .funky-form-field-hint {
  font-size: 0.75rem;
  color: var(--pro-text-secondary);
  margin-top: 0.25rem;
}

.funky-form-field .funky-form-field-error {
  font-size: 0.75rem;
  color: var(--pro-accent-danger);
  margin-top: 0.25rem;
}

.funky-form-field.has-error input,
.funky-form-field.has-error textarea,
.funky-form-field.has-error select {
  border-color: var(--pro-accent-danger) !important;
}

/* ============================================
   SECTIONS LAYOUT
   ============================================ */

.funky-form-sections {
  gap: 0.75rem;
}

.funky-form-section {
  background: var(--pro-bg-elevated);
  border: 1px solid var(--pro-border-color);
  border-radius: var(--form-section-radius);
  overflow: hidden;
}

.funky-form-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: var(--form-section-padding);
  background: var(--pro-bg-secondary);
  border-bottom: 1px solid var(--pro-border-color);
  user-select: none;
}

.funky-form-section-header--collapsible {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.funky-form-section-header--collapsible:hover {
  background: var(--pro-bg-tertiary);
}

.funky-form-section-header--collapsible:focus-visible {
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: calc(-1 * var(--focus-ring-offset));
}

.funky-form-section-icon {
  color: var(--user-accent, var(--pro-accent-primary));
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}

.funky-form-section-title {
  flex: 1;
  font-weight: 600;
  color: var(--pro-text-primary);
}

.funky-form-section-toggle {
  color: var(--pro-text-secondary);
  transition: transform 0.2s ease;
}

.funky-form-section--collapsed .funky-form-section-toggle {
  transform: rotate(-90deg);
}

.funky-form-section-content {
  padding: var(--form-section-padding);
  display: flex;
  flex-direction: column;
  gap: var(--form-gap);
}

/* Section collapse animation */
.funky-form-section-content {
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

.funky-form-section--collapsed .funky-form-section-header {
  border-bottom-color: transparent;
}

/* ============================================
   COLUMNS LAYOUT (CSS Grid)
   ============================================ */

.funky-form-columns {
  display: grid;
  gap: var(--form-gap);
}

/* Default responsive columns */
@media (max-width: 768px) {
  .funky-form-columns {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================
   GRID LAYOUT (Bootstrap-style rows)
   ============================================ */

.funky-form-grid {
  gap: 0;
}

.funky-form-row {
  display: flex;
  flex-wrap: wrap;
  margin-left: calc(-0.5 * var(--form-gap));
  margin-right: calc(-0.5 * var(--form-gap));
  margin-bottom: var(--form-gap);
}

.funky-form-row:last-child {
  margin-bottom: 0;
}

.funky-form-col {
  padding-left: calc(0.5 * var(--form-gap));
  padding-right: calc(0.5 * var(--form-gap));
  flex: 1;
}

/* Bootstrap-like column widths */
.funky-form-col.col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.funky-form-col.col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.funky-form-col.col-md-3 { flex: 0 0 25%; max-width: 25%; }
.funky-form-col.col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.funky-form-col.col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.funky-form-col.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.funky-form-col.col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.funky-form-col.col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.funky-form-col.col-md-9 { flex: 0 0 75%; max-width: 75%; }
.funky-form-col.col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.funky-form-col.col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.funky-form-col.col-md-12 { flex: 0 0 100%; max-width: 100%; }

/* Responsive grid - stack on mobile */
@media (max-width: 768px) {
  .funky-form-row .funky-form-col {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
}

/* ============================================
   FIELDSETS LAYOUT
   ============================================ */

.funky-form-fieldsets {
  gap: 1.5rem;
}

.funky-form-fieldset {
  border: var(--form-fieldset-border);
  border-radius: var(--form-section-radius);
  padding: var(--form-section-padding);
  padding-top: 0.5rem;
  margin: 0;
}

.funky-form-legend {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--user-accent, var(--pro-accent-primary));
  padding: 0 0.5rem;
  margin-left: -0.25rem;
  width: auto;
  float: none;
}

.funky-form-fieldset > .funky-form-field:first-of-type {
  margin-top: 0.75rem;
}

/* ============================================
   TABS LAYOUT
   ============================================ */

.funky-form-tabs {
  gap: 0;
}

.funky-form-tabs .nav-tabs {
  border-bottom: 1px solid var(--pro-border-color);
  margin-bottom: 0;
}

.funky-form-tabs .nav-tabs .nav-link {
  color: var(--pro-text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 0.75rem 1rem;
  margin-bottom: -1px;
  transition: all 0.2s ease;
}

.funky-form-tabs .nav-tabs .nav-link:hover {
  color: var(--pro-text-primary);
  border-bottom-color: var(--pro-border-color);
}

.funky-form-tabs .nav-tabs .nav-link.active {
  color: var(--user-accent, var(--pro-accent-primary));
  border-bottom-color: var(--user-accent, var(--pro-accent-primary));
  background: transparent;
}

.funky-form-tabs .nav-tabs .nav-link:focus-visible {
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.funky-form-tabs .tab-content {
  padding: var(--form-section-padding);
  padding-top: calc(var(--form-section-padding) + 0.5rem);
}

.funky-form-tabs .tab-pane {
  display: none;
}

.funky-form-tabs .tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: var(--form-gap);
}

/* ============================================
   NESTED LAYOUTS
   ============================================ */

/* Sections with nested columns */
.funky-form-section-content.funky-form-columns {
  flex-direction: row;
  flex-wrap: wrap;
}

/* ============================================
   FORM ACTIONS (Submit/Cancel buttons)
   ============================================ */

.funky-form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding-top: var(--form-gap);
  margin-top: var(--form-gap);
  border-top: 1px solid var(--pro-border-color);
}

.funky-form-actions--left {
  justify-content: flex-start;
}

.funky-form-actions--center {
  justify-content: center;
}

.funky-form-actions--spread {
  justify-content: space-between;
}

/* ============================================
   DENSITY OVERRIDES FOR FUNKY.FORM
   ============================================ */

[data-density="compact"] .funky-form-body {
  gap: 0.75rem;
}

[data-density="compact"] .funky-form-section-header {
  padding: 0.625rem 0.875rem;
}

[data-density="compact"] .funky-form-section-content {
  padding: 0.875rem;
  gap: 0.75rem;
}

[data-density="compact"] .funky-form-fieldset {
  padding: 0.875rem;
}

[data-density="compact"] .funky-form-tabs .nav-tabs .nav-link {
  padding: 0.5rem 0.75rem;
}

[data-density="compact"] .funky-form-tabs .tab-content {
  padding: 0.875rem;
}

[data-density="spacious"] .funky-form-body {
  gap: 1.5rem;
}

[data-density="spacious"] .funky-form-section-header {
  padding: 1.25rem 1.5rem;
}

[data-density="spacious"] .funky-form-section-content {
  padding: 1.5rem;
  gap: 1.5rem;
}

[data-density="spacious"] .funky-form-fieldset {
  padding: 1.5rem;
}

[data-density="spacious"] .funky-form-tabs .nav-tabs .nav-link {
  padding: 1rem 1.25rem;
}

[data-density="spacious"] .funky-form-tabs .tab-content {
  padding: 1.5rem;
}

/* ============================================
   HIGH CONTRAST MODE FOR FUNKY.FORM
   ============================================ */

@media (prefers-contrast: high) {
  .funky-form-section {
    border-width: 2px;
  }

  .funky-form-section-header {
    border-bottom-width: 2px;
  }

  .funky-form-fieldset {
    border-width: 2px;
  }

  .funky-form-tabs .nav-tabs {
    border-bottom-width: 2px;
  }

  .funky-form-tabs .nav-tabs .nav-link.active {
    border-bottom-width: 3px;
  }

  .funky-form-section-header--collapsible:focus-visible {
    outline-width: 3px;
  }
}

/* ============================================
   BOOTSTRAP FORM THEME OVERRIDES
   Using --pro-* variables for theme consistency
   ============================================ */

.form-control,
.form-select {
  background-color: var(--pro-input-bg);
  border-color: var(--pro-border);
  color: var(--pro-text-primary);
}

.form-control:focus,
.form-select:focus {
  background-color: var(--pro-input-bg);
  border-color: var(--pro-primary);
  color: var(--pro-text-primary);
}

.form-control::placeholder {
  color: var(--pro-text-tertiary);
}

.form-control:disabled,
.form-select:disabled {
  background-color: var(--pro-bg-tertiary);
  color: var(--pro-text-tertiary);
}

.form-label {
  color: var(--pro-text-primary);
}

.form-text {
  color: var(--pro-text-secondary);
}

/* Input group */
.input-group-text {
  background-color: var(--pro-bg-tertiary);
  border-color: var(--pro-border);
  color: var(--pro-text-primary);
}
