.hidden {
    display: none !important;
}

.menu-fav {
    margin-inline-start: 0.75rem;
}

/* Role Permission Layout Styles - Maximum Specificity to Override Core CSS */

/* Critical styles - loaded first to prevent FOUC */
.permission-checkboxes {
    visibility: hidden;
}

.permission-checkboxes.loaded {
    visibility: visible;
}

/* Base Table Styling */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table th,
.table td {
    vertical-align: middle;
    padding: 12px 8px;
    word-wrap: break-word;
    word-break: break-word;
}

.table-bordered th,
.table-bordered td {
    border: var(--bs-border-width) solid var(--bs-border-color);
}

/* Permission Group Name Column */
.permission-group-name {
    font-weight: 600;
    color: var(--bs-heading-color);
    min-width: 120px;
    width: 20%;
    white-space: normal;
    word-wrap: break-word;
    vertical-align: top;
}

/* Permission Checkboxes Container */
.permission-cell {
    width: 80%;
    vertical-align: top;
}

.permission-checkboxes {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Base Form Check Styling - Maximum Specificity for Override */
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check,
.card .table-responsive .permission-checkboxes .form-check {
    display: flex !important;
    align-items: center !important;
    margin: 2px !important;
    padding: 8px 6px !important;
    border: var(--bs-border-width) solid var(--bs-gray-200) !important;
    border-radius: var(--bs-border-radius) !important;
    background-color: var(--bs-light-bg-subtle) !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-input,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-input,
.card .table-responsive .permission-checkboxes .form-check .form-check-input {
    width: 16px !important;
    height: 16px !important;
    margin: 0 8px 0 0 !important;
    flex-shrink: 0 !important;
    border: var(--bs-border-width) solid var(--bs-border-color) !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
}

body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-label,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-label,
.card .table-responsive .permission-checkboxes .form-check .form-check-label {
    flex: 1 !important;
    margin: 0 !important;
    font-size: 0.875rem !important;
    line-height: 1.4 !important;
    cursor: pointer !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
    word-break: normal !important;
    text-align: left !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Desktop: 5 permissions per row - Equal width table cells - Maximum Specificity */
@media (min-width: 769px) {

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes,
    .card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes,
    .card .table-responsive .permission-checkboxes {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 4px !important;
        width: 100% !important;
        flex-direction: unset !important;
        flex-wrap: unset !important;
        justify-content: unset !important;
        align-items: unset !important;
    }

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check,
    .card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check,
    .card .table-responsive .permission-checkboxes .form-check {
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        text-align: left !important;
        margin: 2px !important;
        margin-bottom: 0 !important;
        margin-top: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Mobile: 1 permission per row - Single column grid - Maximum Specificity */
@media (max-width: 768px) {

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table tbody tr td.permission-group-name,
    .card .card-header .table-responsive .table tbody tr td.permission-group-name,
    .card .table-responsive .permission-group-name {
        width: 30% !important;
        font-size: 0.85rem !important;
    }

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table tbody tr td.permission-cell,
    .card .card-header .table-responsive .table tbody tr td.permission-cell,
    .card .table-responsive .permission-cell {
        width: 70% !important;
    }

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes,
    .card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes,
    .card .table-responsive .permission-checkboxes {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 4px !important;
        width: 100% !important;
        flex-direction: unset !important;
        flex-wrap: unset !important;
        justify-content: unset !important;
        align-items: unset !important;
    }

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check,
    .card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check,
    .card .table-responsive .permission-checkboxes .form-check {
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px 8px !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        text-align: left !important;
        margin: 0 !important;
        margin-bottom: 0 !important;
        margin-top: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-input,
    .card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-input,
    .card .table-responsive .permission-checkboxes .form-check .form-check-input {
        width: 18px !important;
        height: 18px !important;
        margin-right: 8px !important;
        flex-shrink: 0 !important;
    }

    body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-label,
    .card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check .form-check-label,
    .card .table-responsive .permission-checkboxes .form-check .form-check-label {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
    }
}

/* Checkbox State Styling - Using CSS Variables for Theme Support */

/* Checked State - Success Background */
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check input[type="checkbox"]:checked+.form-check-label,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check input[type="checkbox"]:checked+.form-check-label,
.card .table-responsive .permission-checkboxes .form-check input[type="checkbox"]:checked+.form-check-label,
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check:has(input[type="checkbox"]:checked),
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check:has(input[type="checkbox"]:checked),
.card .table-responsive .permission-checkboxes .form-check:has(input[type="checkbox"]:checked) {
    background-color: var(--bs-success-bg-subtle) !important;
    border-color: var(--bs-success-border-subtle) !important;
    color: var(--bs-success) !important;
    font-weight: 500 !important;
}

/* Unchecked State - No Background */
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check input[type="checkbox"]:not(:checked)+.form-check-label,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check input[type="checkbox"]:not(:checked)+.form-check-label,
.card .table-responsive .permission-checkboxes .form-check input[type="checkbox"]:not(:checked)+.form-check-label,
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check:has(input[type="checkbox"]:not(:checked)),
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check:has(input[type="checkbox"]:not(:checked)),
.card .table-responsive .permission-checkboxes .form-check:has(input[type="checkbox"]:not(:checked)) {
    background-color: transparent !important;
    border-color: var(--bs-gray-200) !important;
    color: var(--bs-body-color) !important;
    font-weight: normal !important;
}

/* Hover Effects - Using Theme Variables */
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check:hover,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check:hover,
.card .table-responsive .permission-checkboxes .form-check:hover {
    background-color: var(--bs-secondary-bg) !important;
    border-color: var(--bs-gray-300) !important;
    transform: translateY(-1px) !important;
    box-shadow: var(--bs-box-shadow-sm) !important;
    transition: all 0.2s ease !important;
}

/* Hover Effects for Checked Items */
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check:has(input[type="checkbox"]:checked):hover,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check:has(input[type="checkbox"]:checked):hover,
.card .table-responsive .permission-checkboxes .form-check:has(input[type="checkbox"]:checked):hover {
    background-color: var(--bs-success-border-subtle) !important;
    border-color: var(--bs-success) !important;
    transform: translateY(-1px) !important;
    box-shadow: var(--bs-box-shadow) !important;
    color: var(--bs-success-text-emphasis) !important;
}

/* Fallback for browsers that don't support :has() - Using CSS Variables */
body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check.checked,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check.checked,
.card .table-responsive .permission-checkboxes .form-check.checked {
    background-color: var(--bs-success-bg-subtle) !important;
    border-color: var(--bs-success-border-subtle) !important;
    color: var(--bs-success) !important;
    font-weight: 500 !important;
}

body .row .col-12 .card .card-header form .col-12 .table-responsive .table .table tbody tr td.permission-cell .permission-checkboxes .form-check.checked:hover,
.card .card-header .table-responsive .table tbody tr td.permission-cell .permission-checkboxes .form-check.checked:hover,
.card .table-responsive .permission-checkboxes .form-check.checked:hover {
    background-color: var(--bs-success-border-subtle) !important;
    border-color: var(--bs-success) !important;
    color: var(--bs-success-text-emphasis) !important;
}

/* System Role Readonly Styling */
.form-control[readonly] {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-secondary-color) !important;
    /* cursor: not-allowed !important; */
}

.text-muted {
    color: var(--bs-secondary-color) !important;
    font-size: 0.8125rem !important;
}

.flatpickr-calendar {
    z-index: 2500 !important;
}

.flatpickr-input {
    z-index: 2500 !important;
}