/*
 * JusMaps Design System — control family
 * Canonical dimensions measured from the final Pesquisa selectors.
 * Module styles continue to own layout, width, semantic color and content.
 */
:root {
  --jm-control-height: 37px;
  --jm-control-height-compact: 32px;
  --jm-control-radius: 6px;
  --jm-button-radius: 7px;
  --jm-control-border-width: 1px;
  --jm-control-border: #cbdbe8;
  --jm-control-border-hover: #9fc2df;
  --jm-control-border-focus: #6fb2ef;
  --jm-control-focus-ring: 0 0 0 3px rgba(27, 128, 220, .08);
  --jm-control-text: #234d70;
  --jm-control-placeholder: #85a4bf;
  --jm-control-label: #173f69;
  --jm-control-font-size: var(--jm-type-base, 13px);
  --jm-control-font-weight: var(--jm-weight-regular, 400);
  --jm-control-line-height: 1.4;
  --jm-control-padding-x: 10px;
  --jm-button-font-size: var(--jm-type-sm, 12px);
  --jm-button-font-weight: var(--jm-weight-bold, 700);
  --jm-button-line-height: 1.2;
  --jm-button-padding-x: 14px;
  --jm-button-icon-size: 18px;
  --jm-button-icon-gap: 8px;
  --jm-label-font-size: var(--jm-type-xs, 11px);
  --jm-label-line-height: 1.2;
  --jm-help-font-size: var(--jm-type-xs, 11px);
  --jm-help-line-height: 1.4;
  --jm-control-group-gap: 8px;
  --jm-control-disabled-opacity: .38;
}

/* Shared form controls: inputs and selects use the 37px Pesquisa baseline. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
select {
  box-sizing: border-box;
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  padding: 0 var(--jm-control-padding-x) !important;
  border-width: var(--jm-control-border-width);
  border-radius: var(--jm-control-radius);
  color: var(--jm-control-text);
  font-family: var(--jm-font-sans, Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif) !important;
  font-size: var(--jm-control-font-size) !important;
  font-weight: var(--jm-control-font-weight);
  line-height: var(--jm-control-line-height) !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"])::placeholder,
textarea::placeholder {
  color: var(--jm-control-placeholder);
  opacity: 1;
}

textarea {
  box-sizing: border-box;
  border-width: var(--jm-control-border-width);
  border-radius: var(--jm-control-radius);
  color: var(--jm-control-text);
  font-family: var(--jm-font-sans, Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif) !important;
  font-size: var(--jm-control-font-size) !important;
  line-height: var(--jm-leading-normal, 1.4) !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):hover,
select:hover,
textarea:hover {
  border-color: var(--jm-control-border-hover);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):focus,
select:focus,
textarea:focus {
  border-color: var(--jm-control-border-focus) !important;
  box-shadow: var(--jm-control-focus-ring) !important;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: var(--jm-control-disabled-opacity) !important;
}

/* Primary, secondary and destructive variants keep their existing colors. */
.btn,
.fav-button,
.map-control,
.admin-action,
.maps-general-search-button,
.maps-general-clear-button,
.maps-mini-button,
.maps-selection-actions button,
.maps-results-toolbar button,
.maps-basemap-switch button,
.workspace-actions button,
.support-download,
.support-file-delete,
.diligence-plan-source-actions button {
  box-sizing: border-box;
  min-height: var(--jm-control-height) !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-radius: var(--jm-button-radius);
  font-family: var(--jm-font-sans, Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif) !important;
  font-size: var(--jm-button-font-size) !important;
  font-weight: var(--jm-button-font-weight) !important;
  line-height: var(--jm-button-line-height) !important;
  gap: var(--jm-button-icon-gap);
}

.btn,
.fav-button,
.map-control,
.admin-action,
.maps-general-search-button,
.maps-general-clear-button,
.maps-mini-button,
.maps-selection-actions button,
.maps-results-toolbar button,
.maps-basemap-switch button,
.workspace-actions button,
.support-download,
.support-file-delete,
.diligence-plan-source-actions button {
  height: var(--jm-control-height) !important;
}

.btn svg,
.fav-button .fav-svg,
.map-control svg,
.maps-toolbox button svg,
.maps-fullscreen svg,
.travel-section .btn-inline-svg,
.travel-section .travel-card-actions .travel-svg {
  width: var(--jm-button-icon-size);
  height: var(--jm-button-icon-size);
  flex: 0 0 auto;
}

/* Search and filters retain their own widths and grid placement. */
.field > span,
.fav-field > span:first-child,
.history-filter-field > span,
.ag-filters label,
.ag-form label,
.diligence-plan-target {
  font-size: var(--jm-label-font-size) !important;
  font-weight: var(--jm-weight-bold, 700) !important;
  line-height: var(--jm-label-line-height) !important;
  color: var(--jm-control-label) !important;
}

.field small,
.ag-form small,
.form-help,
.field-hint,
.helper-text {
  font-size: var(--jm-help-font-size) !important;
  line-height: var(--jm-help-line-height) !important;
}

.toolbar-actions { gap: var(--jm-control-group-gap); }

.fav-field,
.history-filter-field,
.ag-filters label,
.ag-form label {
  gap: 5px;
}

.field { gap: 4px; }

.field input:not([type="checkbox"]):not([type="color"]),
.field select,
.fav-field input:not([type="checkbox"]):not([type="color"]),
.fav-field select,
.history-filter-field input:not([type="checkbox"]):not([type="color"]),
.history-filter-field select,
.ag-filters select,
.ag-form input:not([type="checkbox"]):not([type="color"]),
.ag-form select,
.ag-form textarea,
.reports-page .reports-filters input,
.reports-page .reports-filters select,
.settings-form input:not([type="checkbox"]):not([type="color"]),
.settings-form select,
.settings-form textarea,
.support-admin-box input:not([type="file"]),
.support-admin-box select,
.support-admin-box textarea {
  border-color: var(--jm-control-border) !important;
  border-radius: var(--jm-control-radius) !important;
}

.theme-sherlocker-osint input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
.theme-sherlocker-osint select {
  color: #edf8ff !important;
  background-color: #082b4a !important;
  border-color: #2f6f9d !important;
}

.theme-sherlocker-osint .sho-btn {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  border-radius: var(--jm-button-radius);
  font-size: var(--jm-button-font-size) !important;
}

.btn,
.fav-button,
.admin-action,
.map-control,
.maps-general-search-button,
.maps-general-clear-button,
.maps-mini-button,
.maps-selection-actions button,
.maps-results-toolbar button,
.maps-basemap-switch button,
.workspace-actions button,
.support-download,
.support-file-delete,
.diligence-plan-source-actions button {
  padding-right: var(--jm-button-padding-x) !important;
  padding-left: var(--jm-button-padding-x) !important;
}

.btn:hover:not(:disabled),
.fav-button:hover:not(:disabled),
.admin-action:hover:not(:disabled),
.map-control:hover:not(:disabled),
.maps-mini-button:hover:not(:disabled),
.maps-selection-actions button:hover:not(:disabled),
.maps-results-toolbar button:hover:not(:disabled),
.maps-basemap-switch button:hover:not(:disabled),
.workspace-actions button:hover:not(:disabled) {
  transition: background-color .14s ease, border-color .14s ease, box-shadow .14s ease, color .14s ease;
}

button:active:not(:disabled),
a.btn:active {
  filter: brightness(.97);
}

.btn:focus-visible,
.fav-page button:focus-visible,
.favorite-modal button:focus-visible,
.map-control:focus-visible,
.maps-toolbox button:focus-visible,
.maps-mini-button:focus-visible,
.ag-icon-button:focus-visible,
.fav-icon-button:focus-visible,
.nav-btn:focus-visible,
.fav-folder-row > button:first-child:focus-visible,
.ag-category-list button:focus-visible,
.ag-tag-list button:focus-visible,
.maps-hub-tabs button:focus-visible,
.map-close:focus-visible,
.ag-modal-close:focus-visible,
.icon-btn:focus-visible,
.admin-action:focus-visible,
.workspace-actions button:focus-visible,
.support-download:focus-visible,
.support-file-delete:focus-visible {
  outline: 3px solid rgba(34, 119, 190, .42);
  outline-offset: 2px;
}

/* Toolbars and icon buttons share the same height while keeping contextual widths. */
.results-toolbar .toolbar-actions > .btn,
.results-toolbar .toolbar-actions > .toolbar-menu > summary.btn,
.travel-section .travel-top-action.btn,
.travel-section .travel-list-head .workspace-head-actions .btn,
.travel-section .travel-card-actions .btn,
.travel-section .travel-clear,
#section-agenda .ag-quick-actions .btn,
#section-diligencias > .diligence-page-head .workspace-head-actions .btn,
#section-diligencias .diligence-board-toolbar > .btn,
#section-diligencias .diligence-board-toolbar .diligence-import-btn,
#section-diligencias .diligence-plan-source-actions button {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-radius: var(--jm-button-radius) !important;
  font-size: var(--jm-button-font-size) !important;
  font-weight: var(--jm-button-font-weight) !important;
}

.maps-toolbox button,
.fav-icon-button,
.ag-icon-button,
.map-close,
.ag-modal-close,
.ag-detail-head button {
  box-sizing: border-box;
  min-height: var(--jm-control-height) !important;
  height: var(--jm-control-height) !important;
  border-radius: var(--jm-control-radius);
}

.fav-row-actions .fav-icon-button {
  height: var(--jm-control-height-compact) !important;
  min-height: var(--jm-control-height-compact) !important;
}

.maps-toolbox button svg,
.fav-icon-button .fav-svg,
.ag-icon-button svg {
  width: var(--jm-button-icon-size);
  height: var(--jm-button-icon-size);
}

/* Specialized map dialogs use the same control scale as Pesquisa. */
#mapMarkerModal .map-marker-form > .field > input,
#mapMarkerModal .map-marker-link-row .btn,
#mapMarkerModal .map-marker-form-actions .btn,
#section-mapas .maps-general-search-button,
#section-mapas .maps-general-clear-button,
#section-mapas .maps-spatial-context-actions .btn {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  border-radius: var(--jm-button-radius) !important;
  font-size: var(--jm-button-font-size) !important;
}

#section-mapas .maps-spatial-context.is-exact-search .maps-spatial-context-actions .btn {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  font-size: var(--jm-button-font-size) !important;
}

#registerPanel .auth-form input {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  padding: 0 var(--jm-control-padding-x) !important;
  border-radius: var(--jm-control-radius) !important;
}

#section-pesquisa .search-control > input,
#section-pesquisa .search-control > select {
  height: 35px !important;
  min-height: 0 !important;
  padding: 0 10px !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

#section-pesquisa .search-control:focus-within > input,
#section-pesquisa .search-control:focus-within > select {
  border: 0 !important;
  box-shadow: none !important;
}

#mapMarkerModal .map-marker-link-row .btn svg,
#mapMarkerModal .map-marker-form-actions .btn svg {
  width: var(--jm-button-icon-size) !important;
  height: var(--jm-button-icon-size) !important;
}

/* Diligências table controls are inline editors, so their 37px height is shared. */
#section-diligencias .diligence-board-search,
#section-diligencias .diligence-board-sort,
#section-diligencias .diligence-board-search input,
#section-diligencias .diligence-board-sort select {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
}

#section-diligencias .diligence-board-search input {
  height: 100% !important;
  min-height: 0 !important;
}

#section-diligencias .diligence-board-table .diligence-cell-input,
#section-diligencias .diligence-board-table .diligence-cell-select,
#section-diligencias .diligence-board-table .diligence-cell-textline,
#section-diligencias .diligence-plan-table .diligence-cell-select,
#section-diligencias .diligence-plan-table .plan-date-input,
#section-diligencias .diligence-plan-table .plan-notes-input,
#section-diligencias .diligence-plan-target input {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  max-height: var(--jm-control-height) !important;
  box-sizing: border-box;
  border-radius: var(--jm-control-radius) !important;
  font-size: var(--jm-control-font-size) !important;
}

#section-diligencias .diligence-board-table .diligence-anexo-btn,
#section-diligencias .diligence-plan-table .diligence-anexo-btn {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
}

/* Navigation and sidebar actions use the same height; their widths stay contextual. */
.nav-btn,
.fav-folder-row > button:first-child,
.ag-category-list button,
.ag-tag-list button,
.maps-hub-tabs button {
  min-height: var(--jm-control-height) !important;
  height: var(--jm-control-height) !important;
}

.nav-btn {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.nav-btn svg { width: 20px; height: 20px; }

.modal-close {
  height: var(--jm-control-height) !important;
  min-height: var(--jm-control-height) !important;
  border-radius: 50%;
}

/* Compact density is retained for row menus, pagination and in-table actions. */
.action-btn,
.row-actions-menu button,
.row-actions-menu a,
.pagination button,
.fav-pagination button,
.fav-pagination select,
.travel-pagination button,
.travel-pagination select,
.diligence-board-footer > div button,
.diligence-board-footer > div strong,
.diligence-plan-table .plan-row-actions button {
  min-height: var(--jm-control-height-compact) !important;
}

.action-btn,
.maps-mini-button,
.maps-selection-actions button,
.workspace-actions button,
.support-download,
.support-file-delete,
.admin-action {
  border-width: var(--jm-control-border-width);
}

@media (max-width: 700px) {
  .btn,
  .fav-button,
  .map-control,
  .maps-general-search-button,
  .maps-general-clear-button,
  #section-agenda .ag-quick-actions .btn,
  #section-diligencias .diligence-board-toolbar > .btn {
    min-height: var(--jm-control-height) !important;
  }
}
