/* ========================================================================
   Final UI visibility safety layer
   Loaded after app/theme/custom CSS so table-row hover and generic link rules
   cannot hide text inside action menus or other interactive components.
   ======================================================================== */

:root {
    --ui-menu-text: #1e40af;
    --ui-menu-bg: #ffffff;
    --ui-menu-hover-start: #0284c7;
    --ui-menu-hover-end: #2563eb;
    --ui-menu-disabled: #94a3b8;
    --ui-menu-divider: #e2e8f0;
    --ui-dark-text: #0f172a;
    --ui-light-hover: #e0f2fe;
    --ui-hover-border: #0ea5e9;
}

/* Keep the native application font on menus generated by DataTables/AJAX. */
html body .dropdown-menu,
html body .dropdown-menu > li > a,
html body .dropdown-menu .dropdown-item,
html body .tw-dropdown-content,
html body .tw-dropdown-content a,
html body .tw-menu li > a,
html body .dt-button-collection a,
html body .select2-results__option,
html body .ui-autocomplete .ui-menu-item-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Bengali", "Nirmala UI", Arial, sans-serif !important;
}

/* Bootstrap 3/4 action menus: normal state. */
html body .dropdown-menu,
html body .open > .dropdown-menu,
html body .btn-group.open > .dropdown-menu,
html body .dataTables_wrapper .dropdown-menu {
    color: var(--ui-dark-text) !important;
    background: var(--ui-menu-bg) !important;
    border-color: #d7e0ea !important;
}

html body .dropdown-menu > li > a,
html body .dropdown-menu > li > button,
html body .dropdown-menu .dropdown-item,
html body .open > .dropdown-menu > li > a,
html body .btn-group.open > .dropdown-menu > li > a,
html body .dataTables_wrapper .dropdown-menu > li > a {
    color: var(--ui-menu-text) !important;
    background: var(--ui-menu-bg) !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    text-shadow: none !important;
    opacity: 1 !important;
}

html body .dropdown-menu > li > a > i,
html body .dropdown-menu > li > a > svg,
html body .dropdown-menu > li > a > span,
html body .dropdown-menu .dropdown-item > i,
html body .dropdown-menu .dropdown-item > svg,
html body .dropdown-menu .dropdown-item > span {
    color: inherit !important;
    fill: currentColor;
    stroke: currentColor !important;
    opacity: 1 !important;
}

/*
 * Strong specificity is intentional. A dropdown is usually inside a hovered
 * DataTable row; older global rules recolored every nested link blue. These
 * selectors guarantee white text on the blue menu hover in every table/report.
 */
html body .table > tbody > tr:hover > td .dropdown-menu > li:hover > a,
html body .table > tbody > tr:hover > td .dropdown-menu > li > a:hover,
html body .table > tbody > tr:hover > td .dropdown-menu > li > a:focus,
html body table.dataTable > tbody > tr:hover > td .dropdown-menu > li:hover > a,
html body table.dataTable > tbody > tr:hover > td .dropdown-menu > li > a:hover,
html body table.dataTable > tbody > tr:hover > td .dropdown-menu > li > a:focus,
html body .dropdown-menu > li:hover > a,
html body .dropdown-menu > li > a:hover,
html body .dropdown-menu > li > a:focus,
html body .dropdown-menu > .active > a,
html body .dropdown-menu > .active > a:hover,
html body .dropdown-menu > .active > a:focus,
html body .dropdown-menu .dropdown-item:hover,
html body .dropdown-menu .dropdown-item:focus,
html body .dropdown-menu .dropdown-item.active {
    color: #ffffff !important;
    background-color: var(--ui-menu-hover-start) !important;
    background-image: linear-gradient(90deg, var(--ui-menu-hover-start), var(--ui-menu-hover-end)) !important;
    border-color: transparent !important;
    text-decoration: none !important;
    text-shadow: none !important;
    opacity: 1 !important;
}

html body .table > tbody > tr:hover > td .dropdown-menu > li:hover > a *,
html body .table > tbody > tr:hover > td .dropdown-menu > li > a:hover *,
html body table.dataTable > tbody > tr:hover > td .dropdown-menu > li:hover > a *,
html body table.dataTable > tbody > tr:hover > td .dropdown-menu > li > a:hover *,
html body .dropdown-menu > li:hover > a *,
html body .dropdown-menu > li > a:hover *,
html body .dropdown-menu > li > a:focus *,
html body .dropdown-menu > .active > a *,
html body .dropdown-menu .dropdown-item:hover *,
html body .dropdown-menu .dropdown-item:focus * {
    color: #ffffff !important;
    fill: currentColor !important;
    stroke: currentColor !important;
    text-decoration: none !important;
    text-shadow: none !important;
    opacity: 1 !important;
}

/* Disabled action items remain visible but cannot look active. */
html body .dropdown-menu > .disabled > a,
html body .dropdown-menu > .disabled > a:hover,
html body .dropdown-menu > .disabled > a:focus,
html body .dropdown-menu .dropdown-item.disabled,
html body .dropdown-menu .dropdown-item:disabled {
    color: var(--ui-menu-disabled) !important;
    background: #f8fafc !important;
    background-image: none !important;
    cursor: not-allowed !important;
    opacity: 0.78 !important;
}

html body .dropdown-menu > .disabled > a *,
html body .dropdown-menu .dropdown-item.disabled * {
    color: var(--ui-menu-disabled) !important;
}

html body .dropdown-menu .divider,
html body .dropdown-divider {
    height: 1px !important;
    margin: 7px 0 !important;
    background: var(--ui-menu-divider) !important;
    border: 0 !important;
}

/* Daisy/Tailwind dropdown menus used by newer modules. */
html body .tw-dropdown-content,
html body .tw-menu,
html body [class*="tw-dropdown-content"] {
    color: var(--ui-dark-text) !important;
    background: #ffffff !important;
}

html body .tw-dropdown-content li > a,
html body .tw-dropdown-content li > button,
html body .tw-menu li > a,
html body .tw-menu li > button,
html body [class*="tw-dropdown-content"] li > a,
html body [class*="tw-dropdown-content"] li > button {
    color: var(--ui-menu-text) !important;
    background: transparent !important;
    font-weight: 600 !important;
    text-decoration: none !important;
}

html body .tw-dropdown-content li:hover > a,
html body .tw-dropdown-content li:hover > button,
html body .tw-menu li:hover > a,
html body .tw-menu li:hover > button,
html body [class*="tw-dropdown-content"] li:hover > a,
html body [class*="tw-dropdown-content"] li:hover > button {
    color: #ffffff !important;
    background: linear-gradient(90deg, var(--ui-menu-hover-start), var(--ui-menu-hover-end)) !important;
}

html body .tw-dropdown-content li:hover > a *,
html body .tw-dropdown-content li:hover > button *,
html body .tw-menu li:hover > a *,
html body .tw-menu li:hover > button * {
    color: #ffffff !important;
    stroke: currentColor !important;
}

/* DataTables button collections and column-visibility menus. */
html body .dt-button-collection,
html body div.dt-button-collection {
    color: var(--ui-dark-text) !important;
    background: #ffffff !important;
}

html body .dt-button-collection .dt-button,
html body div.dt-button-collection button.dt-button,
html body div.dt-button-collection a.dt-button {
    color: var(--ui-menu-text) !important;
    background: #ffffff !important;
    font-weight: 600 !important;
}

html body .dt-button-collection .dt-button:hover,
html body .dt-button-collection .dt-button:focus,
html body .dt-button-collection .dt-button.active {
    color: #ffffff !important;
    background: linear-gradient(90deg, var(--ui-menu-hover-start), var(--ui-menu-hover-end)) !important;
}

html body .dt-button-collection .dt-button:hover * {
    color: #ffffff !important;
}

/* Select2, autocomplete and typeahead menus. */
html body .select2-dropdown,
html body .select2-results,
html body .ui-autocomplete,
html body .typeahead.dropdown-menu {
    color: var(--ui-dark-text) !important;
    background: #ffffff !important;
}

html body .select2-results__option,
html body .ui-autocomplete .ui-menu-item-wrapper,
html body .typeahead.dropdown-menu > li > a {
    color: var(--ui-dark-text) !important;
    background: #ffffff !important;
    font-weight: 400 !important;
}

html body .select2-container--default .select2-results__option--highlighted[aria-selected],
html body .select2-container--default .select2-results__option[aria-selected="true"]:hover,
html body .ui-autocomplete .ui-menu-item-wrapper.ui-state-active,
html body .typeahead.dropdown-menu > .active > a,
html body .typeahead.dropdown-menu > li > a:hover {
    color: #ffffff !important;
    background: linear-gradient(90deg, var(--ui-menu-hover-start), var(--ui-menu-hover-end)) !important;
}

html body .select2-results__option--highlighted *,
html body .ui-menu-item-wrapper.ui-state-active *,
html body .typeahead.dropdown-menu > .active > a * {
    color: #ffffff !important;
}

/* Sales/Purchase/POS product cards: light hover and dark readable text. */
html body .product_box:hover,
html body .purchase-product-box:hover,
html body [data-variation_id].product_box:hover,
html body #product_list_body [data-variation_id]:hover,
html body #purchase_product_list_body [data-variation_id]:hover {
    color: var(--ui-dark-text) !important;
    background: linear-gradient(145deg, #ecfeff, #dbeafe) !important;
    border-color: var(--ui-hover-border) !important;
    box-shadow: 0 10px 24px rgba(2, 132, 199, 0.20) !important;
}

html body .product_box:hover *,
html body .purchase-product-box:hover *,
html body #product_list_body [data-variation_id]:hover *,
html body #purchase_product_list_body [data-variation_id]:hover * {
    color: var(--ui-dark-text) !important;
    text-decoration: none !important;
    text-shadow: none !important;
}

html body .product_box:hover .text-muted,
html body .purchase-product-box:hover .text-muted,
html body #product_list_body [data-variation_id]:hover .text-muted,
html body #purchase_product_list_body [data-variation_id]:hover .text-muted {
    color: #334155 !important;
}

/* Brand/category controls: light hover; active item stays blue with white text. */
html body .direct-sale-brand:not(.active):hover,
html body .purchase-product-brand:not(.active):hover,
html body .product_brand:not(.active):hover,
html body .product_category:not(.active):hover {
    color: var(--ui-dark-text) !important;
    background: linear-gradient(135deg, #e0f2fe, #dbeafe) !important;
    border-color: #0284c7 !important;
}

html body .direct-sale-brand:not(.active):hover *,
html body .purchase-product-brand:not(.active):hover *,
html body .product_brand:not(.active):hover *,
html body .product_category:not(.active):hover * {
    color: var(--ui-dark-text) !important;
}

html body .direct-sale-brand.active,
html body .direct-sale-brand.active:hover,
html body .purchase-product-brand.active,
html body .purchase-product-brand.active:hover,
html body .product_brand.active,
html body .product_brand.active:hover,
html body .product_category.active,
html body .product_category.active:hover {
    color: #ffffff !important;
    background: linear-gradient(135deg, #2563eb, #0284c7) !important;
    border-color: #1d4ed8 !important;
}

html body .direct-sale-brand.active *,
html body .purchase-product-brand.active *,
html body .product_brand.active *,
html body .product_category.active * {
    color: #ffffff !important;
}

/* Dashboard card labels retain Title Case and readable hover contrast. */
html body .dashboard-page .dashboard-stat-grid > div > div > div > div:last-child > p:first-child {
    text-transform: capitalize !important;
}

html body .dashboard-page .dashboard-stat-grid > div:hover > div > div > div:last-child,
html body .dashboard-page .dashboard-stat-grid > div:hover > div > div > div:last-child * {
    color: var(--ui-dark-text) !important;
    text-shadow: none !important;
}

html body .dashboard-page .dashboard-stat-grid > div:hover > div > div > div:first-child,
html body .dashboard-page .dashboard-stat-grid > div:hover > div > div > div:first-child * {
    color: #ffffff !important;
    stroke: currentColor !important;
}

/* Keep generic content-link hover rules out of component menus. */
html body .content .dropdown-menu a:hover,
html body .content .dropdown-menu a:focus,
html body .content-wrapper .dropdown-menu a:hover,
html body .content-wrapper .dropdown-menu a:focus,
html body .table .dropdown-menu a:hover,
html body table.dataTable .dropdown-menu a:hover {
    color: #ffffff !important;
    text-decoration: none !important;
}

@media print {
    html body .dropdown-menu,
    html body .tw-dropdown-content,
    html body .dt-button-collection {
        display: none !important;
    }
}

/* ========================================================================
   Final action-menu hover enforcement (v2)
   Some legacy table-row hover rules target every nested anchor. The class
   below is also applied by ui-visibility-fix.js with inline !important styles,
   so dynamic DataTable/AJAX action menus always retain readable contrast.
   ======================================================================== */
html body .dropdown-menu > li > a.ui-action-hover-force,
html body .dropdown-menu > li > button.ui-action-hover-force,
html body .dropdown-menu .dropdown-item.ui-action-hover-force,
html body .tw-dropdown-content .ui-action-hover-force,
html body .tw-menu .ui-action-hover-force,
html body .dt-button-collection .ui-action-hover-force,
html body .typeahead.dropdown-menu .ui-action-hover-force,
html body .ui-action-hover-force {
    color: #ffffff !important;
    background-color: #1677d2 !important;
    background-image: linear-gradient(90deg, #0284c7 0%, #2563eb 100%) !important;
    text-decoration: none !important;
    text-shadow: none !important;
    opacity: 1 !important;
}

html body .ui-action-hover-force,
html body .ui-action-hover-force:link,
html body .ui-action-hover-force:visited,
html body .ui-action-hover-force:hover,
html body .ui-action-hover-force:focus,
html body .ui-action-hover-force:active,
html body .ui-action-hover-force *,
html body .ui-action-hover-force:link *,
html body .ui-action-hover-force:visited *,
html body .ui-action-hover-force:hover *,
html body .ui-action-hover-force:focus *,
html body .ui-action-hover-force:active * {
    color: #ffffff !important;
    fill: currentColor !important;
    stroke: currentColor !important;
    text-decoration: none !important;
    text-shadow: none !important;
    opacity: 1 !important;
}

/* Do not allow row-hover styles to leak into an open action menu. */
html body .table > tbody > tr:hover .dropdown-menu,
html body table.dataTable > tbody > tr:hover .dropdown-menu,
html body .table-hover > tbody > tr:hover .dropdown-menu {
    color: #0f172a !important;
    background: #ffffff !important;
}

html body .table > tbody > tr:hover .dropdown-menu > li:not(:hover) > a,
html body table.dataTable > tbody > tr:hover .dropdown-menu > li:not(:hover) > a,
html body .table-hover > tbody > tr:hover .dropdown-menu > li:not(:hover) > a {
    color: #1d4ed8 !important;
    background: #ffffff !important;
    background-image: none !important;
    text-decoration: none !important;
}

html body .table > tbody > tr:hover .dropdown-menu > li:not(:hover) > a *,
html body table.dataTable > tbody > tr:hover .dropdown-menu > li:not(:hover) > a *,
html body .table-hover > tbody > tr:hover .dropdown-menu > li:not(:hover) > a * {
    color: inherit !important;
    text-decoration: none !important;
}
