/* assets/css/app_overrides.css
 * Application-wide design and accessibility fixes, loaded after the framework stylesheets by
 * templates/head.php (the framework files are not edited, see .agents/AGENTS.md).
 */

/* ===================== Buttons ===================== */
/* No green "validate" button: btn-success buttons take the primary style (dark text on amber) */
.btn-success,
.btn-outline-success:hover,
.btn-outline-success:active {
	--btn-color: var(--on-primary, #1F2937);
	--btn-bg: var(--primary, #E5A000);
	--btn-border-color: var(--primary, #E5A000);
	--btn-hover-color: var(--on-primary, #1F2937);
	--btn-hover-bg: var(--primary-hover, #CC8F00);
	--btn-hover-border-color: var(--primary-hover, #CC8F00);
	--btn-active-color: var(--on-primary, #1F2937);
	--btn-active-bg: var(--primary-hover, #CC8F00);
	--btn-active-border-color: var(--primary-hover, #CC8F00);
	--btn-disabled-color: var(--on-primary, #1F2937);
	--btn-disabled-bg: var(--primary, #E5A000);
	--btn-disabled-border-color: var(--primary, #E5A000);
	--btn-focus-shadow-rgb: var(--primary-rgb, 229, 160, 0);
}

.btn-outline-success {
	--btn-color: var(--primary-text, #8A5F00);
	--btn-border-color: var(--primary, #E5A000);
}

/* ===================== Text on the primary color ===================== */
/* Every element filled with the primary color shows its text / icons in --on-primary: black or white chosen from
 * the client color, or forced in Settings > Clients (libraries/client/class.appTheme.php). Light tints
 * (bg-opacity-*) keep the normal text color. */
.bg-primary:not([class*="bg-opacity-"]),
.text-bg-primary,
.badge.bg-primary:not([class*="bg-opacity-"]),
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link,
.page-item.active .page-link,
.pagination .active > .page-link,
.dropdown-item.active,
.dropdown-item:active,
.list-group-item.active,
.progress-bar:not([class*="bg-"]),
.progress-bar.bg-primary,
.btn-check:checked + .btn-outline-primary,
.btn-check:active + .btn-outline-primary,
.btn-outline-primary.active,
.dt-button.active,
.paginate_button.current,
.fc .fc-button-primary:not(:disabled).fc-button-active {
	color: var(--on-primary) !important;
}

/* Select2 & native <select> options: Limitless uses light backgrounds (--white, --gray-200, --gray-300) for
 * dropdown options and highlighted states, so option text must always use the dark body color (--body-color)
 * instead of --on-primary (which is #FFFFFF when the client theme uses white text on primary fills). */
select option,
.select2-dropdown,
.select2-results__option {
	background-color: var(--white, #FFFFFF);
	color: var(--body-color, #1F2937) !important;
}
.select2-results__option[aria-selected="true"] {
	background-color: var(--gray-200, #F3F4F6) !important;
	color: var(--body-color, #1F2937) !important;
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-results__option.select2-results__option--highlighted {
	background-color: var(--alpha-primary, #FCF3DE) !important;
	color: var(--body-color, #1F2937) !important;
}
.select2-results__option[aria-disabled="true"] {
	color: var(--gray-500, #9CA3AF) !important;
}
.select2-selection--multiple .select2-selection__choice {
	background-color: var(--gray-200, #F3F4F6);
	color: var(--body-color, #1F2937);
}

/* Light tints of the primary color (bg-opacity-*, subtle backgrounds): the page text color, never --on-primary
 * (mmi.css forces --on-primary on every .badge.bg-primary, white text would be invisible on a pale tint).
 * Brand icons keep --primary-text. */
.bg-primary[class*="bg-opacity-"],
.badge.bg-primary[class*="bg-opacity-"],
.bg-primary-subtle,
.badge.bg-primary-subtle {
	color: var(--body-color, #1F2937) !important;
}
.bg-primary[class*="bg-opacity-"] .icon,
.bg-primary-subtle .icon {
	color: var(--primary-text) !important;
}
/* Theme stylesheet (framework file) gives the subtle variants a blue */
.badge.bg-primary-subtle,
.bg-primary-subtle {
	background-color: var(--alpha-primary) !important;
}
.badge.text-primary-emphasis,
.text-primary-emphasis {
	color: var(--primary-text) !important;
}

/* Secondary texts inside a primary fill: same color, slightly dimmed (never the gray of the page) */
.bg-primary:not([class*="bg-opacity-"]) :is(.text-muted, .text-body, .text-body-secondary, .text-secondary, .text-dark, .text-black, .text-white, .opacity-75, small),
.text-bg-primary :is(.text-muted, .text-body, .text-body-secondary, .text-secondary, .text-dark, .text-black, .text-white, small) {
	color: var(--on-primary) !important;
}

.bg-primary:not([class*="bg-opacity-"]) :is(.text-muted, .text-body-secondary, .text-secondary),
.text-bg-primary :is(.text-muted, .text-body-secondary, .text-secondary) {
	opacity: 0.85;
}

/* Icons follow the surrounding text color (icons.css only sets fill on body/.card-body, not on .alert or svg.icon) */
svg.icon {
	fill: currentColor;
}

.alert .icon:not([class*="text-"]),
.bg-primary:not([class*="bg-opacity-"]) .icon,
.text-bg-primary .icon,
.btn-primary .icon {
	color: inherit;
	fill: currentColor;
}

/* Close button on a primary fill: white cross only when the text is light */
.bg-primary:not([class*="bg-opacity-"]) .btn-close {
	filter: var(--on-primary-close-filter, none);
}

/* White text on light fills (warning / info) fails WCAG contrast: dark text instead */
.btn-warning.text-white,
.btn-info.text-white,
.bg-warning.text-white,
.bg-info.text-white,
.bg-warning .text-white,
.bg-info .text-white {
	color: var(--body-color, #1F2937) !important;
}

/* ===================== Cards ===================== */
/* Cards keep the soft elevation of the design system: shadow utilities are neutralised */
.card.shadow-sm,
.card.shadow,
.card.shadow-lg {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
}

.card.shadow-sm:hover,
.card.shadow:hover,
.card.shadow-lg:hover {
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.07) !important;
}

/* ===================== Focus & skip link ===================== */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid var(--primary-text, #8A5F00);
	outline-offset: 2px;
}

.app-skip-link {
	position: absolute;
	left: 8px;
	top: -48px;
	z-index: 30000;
	padding: 8px 14px;
	border-radius: var(--border-radius, 0.5rem);
	background: var(--primary, #E5A000);
	color: var(--on-primary, #1F2937);
	font-weight: 600;
	transition: top 0.15s ease;
}

.app-skip-link:focus {
	top: 8px;
}

/* ===================== Responsive ===================== */
/* Header notifications dropdown: never wider than the screen */
.dropdown-menu-alerts {
	max-width: calc(100vw - 16px);
}

/* Theme stylesheet (assets/themes/default/css/custom.css, framework file): amber text on a light tint on hover */
.btn-check:not(:checked) + .btn-outline-primary:hover {
	color: var(--primary-text) !important;
}
.btn-check:not(:checked) + .btn-outline-primary:hover .icon,
.btn-check:not(:checked) + .btn-outline-primary:hover svg {
	color: var(--primary-text) !important;
	fill: var(--primary-text) !important;
	stroke: var(--primary-text) !important;
}

/* Styled lists (assets/js/app_select.js): native select of an auto-styled list, hidden like Select2's own
 * select2-hidden-accessible (kept accessible to screen readers, out of the layout) */
.app-select-hidden {
	border: 0 !important;
	clip: rect(0 0 0 0) !important;
	height: 1px !important;
	margin: -1px !important;
	overflow: hidden !important;
	padding: 0 !important;
	position: fixed !important;
	width: 1px !important;
}

/* Groups page (rights by category): the category names of the first header row wrap and never set the width
 * of their columns (a category with a single right is narrower than its name). DataTables draws the header in a
 * separate table (scrollX): a header cell wider than its column shifted the header from the body. */
#groups-form .dataTables_scrollHead thead tr:first-child th,
#groups-form table.datatable thead tr:first-child th {
	white-space: normal;
	overflow-wrap: anywhere;
	hyphens: auto;
	line-height: 1.2;
	vertical-align: middle;
	text-align: center;
}

/* Select2 list in an .input-group (assets/js/app_select.js): Select2 sets width: 100% on its container, used as
 * flex basis it wrapped the list on its own line. Same rule as Bootstrap's .form-control in an input group:
 * minimal basis, the container grows to fill the remaining space. */
.input-group > .select2-container {
	width: 1% !important;
	flex: 1 1 auto;
	min-width: 0;
}

/* List marked .flex-grow-0 (theme rule in components.css): keeps its natural width */
.input-group > .select2-hidden-accessible.flex-grow-0 + .select2-container {
	width: auto !important;
}

/* Page header actions (e.g. plugins/mod_crm/templates/pages/company.php): spaced by the gap, under the title
 * below lg, on one row. Buttons reduced to their icon on small screens keep their label for screen readers
 * (visually hidden .app-btn-label) and in their title tooltip:
 * - .app-btn-compact: secondary action, icon only below lg;
 * - .app-header-primary: main action, label kept down to sm, then icon only; at the right end of the row. */
.app-header-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
}

@media (max-width: 991.98px) {
	.page-header .page-header-content.d-lg-flex {
		display: flow-root;
	}

	.page-header .page-header-content.d-lg-flex > .header-elements:not([class*="py-"]):has(.btn, button, a, input, select, .badge, .dropdown),
	.page-header .page-header-content.d-lg-flex > :last-child:not(:first-child):not([class*="py-"]):has(.btn, button, a, input, select, .badge, .dropdown) {
		margin-top: 0.75rem;
		margin-bottom: 0.75rem;
	}

	.page-header .page-header-content.d-lg-flex > .d-lg-flex:last-child:not(:first-child) {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 0.5rem;
	}

	.app-header-actions {
		justify-content: flex-start;
		margin-top: 0.75rem;
		margin-bottom: 0.75rem;
	}

	.app-header-actions > .app-header-primary {
		margin-left: auto;
	}

	.app-btn-compact .app-btn-label {
		position: absolute !important;
		width: 1px !important;
		height: 1px !important;
		padding: 0 !important;
		margin: -1px !important;
		overflow: hidden !important;
		clip: rect(0, 0, 0, 0) !important;
		white-space: nowrap !important;
		border: 0 !important;
	}

	.app-btn-compact > .icon,
	.app-btn-compact > .app-spinner {
		margin-right: 0 !important;
	}
}

@media (max-width: 575.98px) {
	.app-header-primary .app-btn-label {
		position: absolute !important;
		width: 1px !important;
		height: 1px !important;
		padding: 0 !important;
		margin: -1px !important;
		overflow: hidden !important;
		clip: rect(0, 0, 0, 0) !important;
		white-space: nowrap !important;
		border: 0 !important;
	}

	.app-header-primary > .icon,
	.app-header-primary > .app-spinner {
		margin-right: 0 !important;
	}
}

/* Phones: icon-only header buttons get a square padding so the whole row fits down to 320px */
@media (max-width: 575.98px) {
	.app-header-actions > .app-btn-compact,
	.app-header-actions > .dropdown > .app-btn-compact,
	.app-header-actions > .app-header-primary {
		padding-left: 0.625rem;
		padding-right: 0.625rem;
	}
}

/* Match --card-inner-border-radius to --card-border-radius (--border-radius-xl in mmi.css) so .card-header and
 * .card-footer with a background (e.g. .bg-white) do not overflow and hide the rounded corners of the card border */
.card {
	--card-inner-border-radius: calc(var(--card-border-radius, var(--border-radius-xl)) - var(--card-border-width, var(--border-width, 1px)));
}

/* Layout & Accessible Scrollbars across all platforms (macOS, Windows, Linux)
 * Ensures .content-inner always scrolls smoothly and renders an accessible, visible scrollbar */
.content-wrapper {
	min-height: 0 !important;
}

.content-inner {
	flex: 1 1 auto;
	min-height: 0 !important;
	height: 100%;
	overflow-y: auto !important;
	-webkit-overflow-scrolling: touch;
	scroll-behavior: auto !important; /* Prevents dropped/lagging wheel events on macOS & discrete mice */
}

/* Styled scrollbars for all scrollable containers (matching Natais palette) */
* {
	scrollbar-width: thin;
	scrollbar-color: rgba(var(--primary-rgb, 229, 160, 0), 0.45) transparent;
}

::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

::-webkit-scrollbar-track {
	background: transparent;
}

::-webkit-scrollbar-thumb {
	background-color: rgba(var(--primary-rgb, 229, 160, 0), 0.35);
	border-radius: 6px;
	border: 2px solid transparent;
	background-clip: content-box;
	transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
	background-color: var(--primary, #E5A000);
}


