/* Role form — permission modules & aligned checkboxes (LTR + RTL)
   Also reused by Dashboard User Assigned Roles (grouped-checkbox-selector.js) */

.role-perm-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.role-perm-selected-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #4b5563);
}

.role-active-toggle {
    width: 100%;
    max-width: 14rem;
}

.role-permissions-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.role-module-card {
    border: 1px solid var(--surface-border, #e5e7eb);
    border-radius: 0.75rem;
    background: var(--surface-muted, #f8fafc);
    overflow: hidden;
}

.role-module-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--surface-card, #fff);
    border-bottom: 1px solid var(--surface-border, #e5e7eb);
}

.role-module-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 650;
    color: var(--text-primary, #111827);
    letter-spacing: 0.01em;
}

.role-module-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.role-module-btn {
    appearance: none;
    border: 1px solid var(--surface-border, #d1d5db);
    background: var(--surface-card, #fff);
    color: var(--text-primary, #374151);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.role-module-btn:hover {
    border-color: var(--primary, #0d6efd);
    color: var(--primary, #0d6efd);
    background: var(--primary-light, #eef5ff);
}

.role-module-btn--muted {
    color: var(--text-muted, #6b7280);
}

.role-perm-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
    gap: 0.5rem;
    padding: 0.85rem 1rem 1rem;
}

.role-perm-item {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    padding: 0.55rem 0.7rem;
    min-height: 2.4rem;
    border: 1px solid var(--surface-border, #e5e7eb);
    border-radius: 0.55rem;
    background: var(--surface-card, #fff);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.role-perm-item:hover {
    border-color: var(--primary, #0d6efd);
    box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.12);
}

.role-perm-checkbox {
    position: static !important;
    float: none !important;
    margin: 0 !important;
    flex: 0 0 auto;
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--primary, #0d6efd);
    cursor: pointer;
}

.role-perm-label {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text-primary, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-perm-item:has(.role-perm-checkbox:checked) {
    border-color: var(--primary, #0d6efd);
    background: var(--primary-light, #eef5ff);
}

.role-perm-item:has(.role-perm-checkbox:focus-visible) {
    outline: 2px solid var(--primary, #0d6efd);
    outline-offset: 1px;
}

[dir="rtl"] .role-perm-item {
    text-align: right;
}

@media (max-width: 576px) {
    .role-perm-list {
        grid-template-columns: 1fr;
    }

    .role-module-header {
        align-items: flex-start;
        flex-direction: column;
    }
}
